Java – use stack swap API

I have tried to upgrade the stack overflow problem with the stack exchange API and failed I've tried a lot, but I didn't get it to work

website:

http://api.stackexchange.com/2.2/questions/35007869/upvote

file

https://api.stackexchange.com/docs/upvote-question

Jason data:

{
  "key" : "my key","access_token" : "my token","site" : "stackoverflow.com","preview" : "false","filter": "default"
}

I try to pass the fiddler with the following parameters

User-Agent: fiddler
Host: api.stackexchange.com
Content-Length: 159
Content-Type: application/json; charset=utf-8

And post methods But I failed with the following error message

error_id=400
error_message=site is required
error_name=bad_parameter

But I have provided this site in my JSON object So any help will be very considerable

to update

After trying this fiddler, I received the following message

Solution

You need to send them as form data. Using JavaScript will be like this:

var request = new XMLHttpRequest();
request.open('POST','http://api.stackexchange.com/2.2/questions/35007869/upVote',true);

var formData = new FormData();
formData.append('key','my key');
formData.append('access_token','my token');
formData.append('site','stackoverflow.com');
formData.append('preview','false');
formData.append('filter','default');

request.send(formData);

This is an Android: http://www.onlymobilepro.com/2013/03/16/submitting-android-form-data-via-post-method/ Guide to doing

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>