[Stackoverflow] [Progress OpenEdge ABL] how to make a http post with param and json payload at same time with openedge requestBuilder

Status
Not open for further replies.
H

Heber Paes Fomin

Guest
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:

Code:
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:

Code:
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...
 
Status
Not open for further replies.
Top