|
Post by wbtcpip on Dec 7, 2023 15:44:22 GMT 1
ciao GB Friends, i have to post a json string to a remote server.
no problem when posting xml but i'm failing to post a json string.
an exemple of json string that i have to send is this:
{ "nowPlaying": [ { "artist": "2+Small", "duration": "00:02:55", "id": "12854", "status": "playing", "time": "2023-12-07T15:17:27+00:00", "title": "Feel+4+Me+(Radio+Mix)", "type": "song" } ] }
Let me explain my code:
Dim myhttpget As Object dim jsonstring as string Set myhttpget = CreateObject("WinHttp.WinHttpRequest.5.1") myhttpget.Open "POST", "https://server....", False myhttpget.setRequestHeader "Content-Type", "application/json" myhttpget.setRequestHeader "User-Agent", "myapp" myhttpget.Send jsonstring
in the jsonstring i load the text that i showed above
but the server always reply to me Error=400 - Bad Request
so maybe in json i do not have to send the string as it appears but data must be formatted in someway?
|
|
|
Post by (X) on Dec 7, 2023 19:36:20 GMT 1
BING says the JSON data is at least formatted within the JSON guidelines.
It may be as you suggest, that the actual format the server expect is slightly different.
Can you post the XML file?
|
|
|
Post by wbtcpip on Dec 7, 2023 19:39:15 GMT 1
i attach the instructions i received
|
|
|
Post by (X) on Dec 7, 2023 20:00:08 GMT 1
Nothing wrong jumps out to me or BING :)
I was wondering who generates the ID though.
|
|
|
Post by wbtcpip on Dec 7, 2023 22:00:18 GMT 1
it could be that the json string must be unicode? me i'm passing utf8
according to them the id is unique number to reference the song inside my library so it's not so important
|
|