J jobykpaul Member Licensed User Longtime User Feb 5, 2020 #1 Hi I have to upload data to the server by using http POST request and data format is JOSN string. I follow the below code... Dim Map1 As Map Map1.Initialize Dim JSONGenerator As JSONGenerator Dim JSONstring As String Map1.put("username","user1") Map1.put("password","abcdef") JSONGenerator.Initialize(Map1) Dim j As HttpJob j.Initialize("", Me) j.PostString("http://54.385.735.10/mobility/api/login",JSONGenerator.ToString) Wait For (j) JobDone(j As HttpJob) If j.Success Then Msgbox(j.GetString,"") endif The JSON string is showing in the correct format. When we try from the app, the response from the server is blank, but the same i tried from online Http POST tool it is working. Please help me to solve the issue. Thank You
Hi I have to upload data to the server by using http POST request and data format is JOSN string. I follow the below code... Dim Map1 As Map Map1.Initialize Dim JSONGenerator As JSONGenerator Dim JSONstring As String Map1.put("username","user1") Map1.put("password","abcdef") JSONGenerator.Initialize(Map1) Dim j As HttpJob j.Initialize("", Me) j.PostString("http://54.385.735.10/mobility/api/login",JSONGenerator.ToString) Wait For (j) JobDone(j As HttpJob) If j.Success Then Msgbox(j.GetString,"") endif The JSON string is showing in the correct format. When we try from the app, the response from the server is blank, but the same i tried from online Http POST tool it is working. Please help me to solve the issue. Thank You
DonManfred Expert Licensed User Longtime User Feb 5, 2020 #2 Please use [CODE]code here...[/CODE] tags when posting code. You prrobably need to set a correct contenttype B4X: Copy j.PostString(...) j.GetRequest.SetContentType("application/json")' The line AFTER poststring.... Last edited: Feb 5, 2020 Upvote 0
Please use [CODE]code here...[/CODE] tags when posting code. You prrobably need to set a correct contenttype B4X: Copy j.PostString(...) j.GetRequest.SetContentType("application/json")' The line AFTER poststring....
nibbo Active Member Licensed User Longtime User Feb 5, 2020 #3 You need to set the ContentType for JSON. Add B4X: Copy j.GetRequest.SetContentType("application/json") after j.PostString EDIT: I was too slow to beat DonManfred… Upvote 0
You need to set the ContentType for JSON. Add B4X: Copy j.GetRequest.SetContentType("application/json") after j.PostString EDIT: I was too slow to beat DonManfred…
J jobykpaul Member Licensed User Longtime User Feb 5, 2020 #4 DonManfred said: Please use [CODE]code here...[/CODE] tags when posting code. You prrobably need to set a correct contenttype B4X: Copy j.[I]PostString[/I](...) j.GetRequest.SetContentType("application/json")' The line AFTER poststring.... Click to expand... Thank You for your promt reply it solve the issue when i add contenttype. Also i was use the old http library too.... Upvote 0
DonManfred said: Please use [CODE]code here...[/CODE] tags when posting code. You prrobably need to set a correct contenttype B4X: Copy j.[I]PostString[/I](...) j.GetRequest.SetContentType("application/json")' The line AFTER poststring.... Click to expand... Thank You for your promt reply it solve the issue when i add contenttype. Also i was use the old http library too....
DonManfred Expert Licensed User Longtime User Feb 5, 2020 #5 jobykpaul said: Also i was use the old http library too.... Click to expand... you should switch to okhttputils2 and okhttp Upvote 0
jobykpaul said: Also i was use the old http library too.... Click to expand... you should switch to okhttputils2 and okhttp
J jobykpaul Member Licensed User Longtime User Feb 5, 2020 #6 DonManfred said: you should switch to okhttputils2 and okhttp Click to expand... Done Upvote 0