L
L
los angels2015-11-19 00:31:59
Java
los angels, 2015-11-19 00:31:59

How to send a correct POST request??

To get a token for Yandex.disk, in theory, you need to send a Post request to the address:

https://oauth.yandex.ru/authorize?" +"response_type="+response_type+"&client_id="+client_id.>

After that, I should get a response like:
https://oauth.yandex.ru/verification_code#access_token=<токен>&token_type=bearer&expires_in=<время жизни>

Can you please tell me how to make this request?
I tried to send it but my request doesn't work:
HttpClient httpClient = new DefaultHttpClient();
    HttpPost post = new HttpPost("https://oauth.yandex.ru/authorize?" +
    "response_type="+response_type+
    "&client_id="+client_id);
    HttpResponse response;
    response = httpClient.execute(post);
    post.abort();
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2015-11-19
@bromzh

You didn't read the docs well . We need not a post-request, but to direct the user to a page at a specific address. Apparently, you write something for android. So, they also indicate how to process a token on a mobile phone.
In general:
1) When you send a post, then all the data must be in the request body, and not in the URL parameters. Take a closer look at the docks: get-requests are formed there via URL, headers and other things are specified for post-requests. It's hard to confuse them.
2) Forming a URL with parameters manually is very bad. For such purposes, there is this . And in general, the string must be formed through the builder .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question