خرید بک لینک

Vote count: 0

I want to use an API in my app. In it's guide, it shows me to make a coection like this-

$.ajax(
{ type: "POST",
 url: baseUrl + "query/",
contentType: "application/json; charset=utf-8",
 dataType: "json",
headers: {
 "Authorization": "Bearer " + accessToken,
"ocp-apim-subscription-key": subscriptionKey
},
data: JSON.stringify({q: text, lang: "en"}), //text is a String variable
success: function(data) { prepareResponse(data); },
error: function() { respond(messageIntealError); } });ufeff

I'm translating this call for android. I've used HttpURLCoection like this-

URL url = new URL(baseUrl + "query/");
HttpURLCoection urlcon = (HttpURLCoection) url.openCoection();

Now I can use setRequestProperty() to set the Header and contentType part. But I don't know how to set the data and dataType part.

Please help me.

asked 1 min ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 27 تير 1395 ساعت: 1:19

صفحه بندی