1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

how to make a http post with param and json payload at same time with openedge requestBuilder

Discussão em 'StackOverflow' iniciado por fdantas, Outubro 30, 2020.

  1. fdantas

    fdantas Administrator Moderador

    I need to send a post to an url with parameters and with a json payload. In Postman, for example, I made this:

    post http://address.com?key=As8941a1891389123812312381923 and in the body put the json in RAW format. On header I just put a Content-type application/json, and it works fine.

    In openedge I tryed this:

    oJson = new JsonObject;
    oJson:add('...blablabla',payloadData).
    assign cURL = 'http://address.com?key=As8941a1891389123812312381923'.
    oHttpClient = ClientBuilder:Build():Client.
    Assign oRequest = RequestBuilder:post(cURL,oJson)
    :Content-type('application/json')
    :AcceptJson()
    :Request.
    Assign oResponse = oHttpClient:Execute(oRequest).


    But, I got a 403 error from the server. it seems the problem is when I try to send ?key=xxxx parameter with the URL and also a json payload at same time, or, I made a mistake in cUrl formation.

    In other kind of posts I made (and that works ok) without a json payload, when has some parameters, usually I have to send the parameters separately, like this:

    ASSIGN id = trim("db=" + trim(db) + "&lg=" + trim(lg) + "&sh=" + trim(sh) +
    "&sxml=" + trim(argumentos))

    htmlRequest = trim(id).
    oRequestBody = new String(htmlRequest).

    oRequest = RequestBuilder:post(trim(cURL),oRequestBody)
    :AcceptHtml()
    :Request.
    oResponse = ClientBuilder:Build():Client:Execute(oRequest).


    how to send both parameter "?key=...." and a json payload at same time with openedge RequestBuilder?

    Does anybody can help?

    Thanks in advance

    Continue reading...

Compartilhe esta Página