ThePuiu Active Member Licensed User Longtime User Oct 30, 2023 #1 Hello! I want to make a POST call to a server (which I don't control). The call requires a parameter in the form of a string that respects the format: "[{"param1": "value1"},{ "data": "2023-10-30"}]" Click to expand... if I try to make the call like this: Dim parametrii As Map parametrii.Initialize parametrii.Put("param1","155810") parametrii.Put("data","2023-10-30") j.PostMultipart(destinationUrl,parametrii,Null) Click to expand... the response from the server is 200 but I receive an error message that the parameters are not in the expected format. how can i get the required format? Thank you!
Hello! I want to make a POST call to a server (which I don't control). The call requires a parameter in the form of a string that respects the format: "[{"param1": "value1"},{ "data": "2023-10-30"}]" Click to expand... if I try to make the call like this: Dim parametrii As Map parametrii.Initialize parametrii.Put("param1","155810") parametrii.Put("data","2023-10-30") j.PostMultipart(destinationUrl,parametrii,Null) Click to expand... the response from the server is 200 but I receive an error message that the parameters are not in the expected format. how can i get the required format? Thank you!
walterf25 Expert Licensed User Longtime User Oct 30, 2023 #2 ThePuiu said: Hello! I want to make a POST call to a server (which I don't control). The call requires a parameter in the form of a string that respects the format: if I try to make the call like this: the response from the server is 200 but I receive an error message that the parameters are not in the expected format. how can i get the required format? Thank you! Click to expand... I believe you need to send the parameters in JSON format, do a search for Json library and look up examples how to convert a map or a list of maps into Json format. Upvote 0
ThePuiu said: Hello! I want to make a POST call to a server (which I don't control). The call requires a parameter in the form of a string that respects the format: if I try to make the call like this: the response from the server is 200 but I receive an error message that the parameters are not in the expected format. how can i get the required format? Thank you! Click to expand... I believe you need to send the parameters in JSON format, do a search for Json library and look up examples how to convert a map or a list of maps into Json format.
DonManfred Expert Licensed User Longtime User Oct 31, 2023 #3 ThePuiu said: that respects the format: Click to expand... it´s just a json-string http://basic4ppc.com:51042/json/index.html B4X: Dim parser As JSONParser parser.Initialize("[{"param1": "value1"},{ "data": "2023-10-30"}]" ) Dim jRoot As List = parser.NextArray For Each coljRoot As Map In jRoot Dim param1 As String = coljRoot.Get("param1") Next By checking how to parse such a string you find out that it starts with a LIST. Inside this list are Maps. If you want to create such go the reverse way - Create a list - Add Maps with the content to this list - Use jsongenerator to create a json out of the List. - Post this json-string then Last edited: Oct 31, 2023 Upvote 0
ThePuiu said: that respects the format: Click to expand... it´s just a json-string http://basic4ppc.com:51042/json/index.html B4X: Dim parser As JSONParser parser.Initialize("[{"param1": "value1"},{ "data": "2023-10-30"}]" ) Dim jRoot As List = parser.NextArray For Each coljRoot As Map In jRoot Dim param1 As String = coljRoot.Get("param1") Next By checking how to parse such a string you find out that it starts with a LIST. Inside this list are Maps. If you want to create such go the reverse way - Create a list - Add Maps with the content to this list - Use jsongenerator to create a json out of the List. - Post this json-string then