How to send json object to someone else's api?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
23 views
There is a js request like this:
url : 'example.com/json.php', jsonp : 'callback', data : {"json" : DataJson}, type : 'GET', dataType : "jsonp",


You need to rewrite it on the server:
DataJson = "{'senderCityId':'506','receiverCityId':'320'}" uri = URI("example.com/json.php") params = {"json" => DataJson} uri.query = URI.encode_www_form(params) res = Net::HTTP.get_response(uri) h = JSON.parse(res.body)


The service returns an error that the expected json.
It turns out that is sent to the server
http://example.com/json.php?json={'senderCityId':'506','receiverCityId':'320'}

In any form whatsoever is sent a json object?
by | 23 views

1 Answer

0 like 0 dislike
Somehow so. It is necessary in the body of the request to add the data and not in query.
by

Related questions

0 like 0 dislike
1 answer
asked Sep 1, 2019 by AlanIkaev
0 like 0 dislike
1 answer
asked Aug 3, 2019 by AlanIkaev
0 like 0 dislike
1 answer
asked Jul 10, 2019 by AlanIkaev
0 like 0 dislike
1 answer
asked Jul 2, 2019 by AlanIkaev
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users