Hi,
currently I am trying to access a api for sending letters. The company provides a php class, however I want to use B4J.
Here is my problem:
In the php class one can see that the getPrice() funtion creates a Get request, but still has a post field:
Is it currently possible to implement this in B4J? Somehow I have to modify the request body, but it doesn't seem that there is a method/option for this.
Btw. this is how my current code looks like (I use a Post requets here as it makes the most sense for me, but the server returns a error, saying that the rescource (I guess the json string is meant) were not found)
Any ideas?
Jan
currently I am trying to access a api for sending letters. The company provides a php class, however I want to use B4J.
Here is my problem:
In the php class one can see that the getPrice() funtion creates a Get request, but still has a post field:
B4X:
$opt_array[CURLOPT_CUSTOMREQUEST] = 'GET';
$opt_array[CURLOPT_POSTFIELDS] = $json;
Is it currently possible to implement this in B4J? Somehow I have to modify the request body, but it doesn't seem that there is a method/option for this.
Btw. this is how my current code looks like (I use a Post requets here as it makes the most sense for me, but the server returns a error, saying that the rescource (I guess the json string is meant) were not found)
B4X:
Sub GetPrice
Dim Request As Map
Request.Initialize
Request.Put("auth",CreateMap("apikey":"KEY","username":"NAME"))
Request.Put("letter",CreateMap("specification":CreateMap("page":"1","color":"1","mode":"simplex","ship":"national")))
Dim J As JSONGenerator
J.Initialize(Request)
Dim H As HttpJob
H.Initialize("GetPrice",Me)
H.PostString("https://sandbox.letterxpress.de/v1/getPrice",J.ToString)
H.GetRequest.SetContentType("application/json")
H.GetRequest.SetHeader("User-Agent","MozillaXYZ/1.0")
Wait For (H) JobDone(H As HttpJob)
Log(H.GetString)
End Sub
Any ideas?
Jan
Last edited: