I want to do a httpJob to a rest api. This is the string I have to send:
I use this b4x code, the problem is the categories part, how can I past this in a map?
I get the following error:
ResponseError. Reason: , Response: {"code":"rest_invalid_param","message":"Ongeldige parameter(s): categories","data":{"status":400,"params":{"categories":"categories[0] wrong type object."},"details":{"categories":{"code":"rest_invalid_type","message":"categories[0] wrong type object.","data":{"param":"categories[0]"}}}}}
The problem is the map A, but I can't find out the correct syntax.
send string:
"name": "REST API TEST",
"type": "simple",
"regular_price": "21.99",
"description": "Long description",
"short_description": "Short description",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
I use this b4x code, the problem is the categories part, how can I past this in a map?
b4x code:
Sub Button1_Click
Dim D As Map
D.Initialize
D.Put("name","REST API TEST")
D.Put("type", "simple")
D.Put("regular_price", "21.99")
D.Put("description", "Long description")
D.Put("short_description", "Short description")
Dim A As Map
A.Initialize
A.Put("id", "9")
A.Put("id", "14")
D.Put("categories",A)
Dim Job As HttpJob
Job.Initialize("Register",Me)
Job.Username = "?????????????????"
Job.Password = "?????????????????????????????????"
Job.PostMultipart("https://???????????????????/wp-json/wc/v3/products" , D,Null)
Job.GetRequest.SetHeader("Content-Type", "application/json")
Job.GetRequest.SetContentEncoding("text/plain")
End Sub
I get the following error:
ResponseError. Reason: , Response: {"code":"rest_invalid_param","message":"Ongeldige parameter(s): categories","data":{"status":400,"params":{"categories":"categories[0] wrong type object."},"details":{"categories":{"code":"rest_invalid_type","message":"categories[0] wrong type object.","data":{"param":"categories[0]"}}}}}
The problem is the map A, but I can't find out the correct syntax.