I'm working with Microsoft Teams API with HTTP requests.
When I use Graph Explorer to retrieve my channel messages, it works fine.
However, when I try to use another platform to send the HTTP request, it shows something like \u3042\u308a\u304c\u3068\u3046 instead of Chinese or Japanese.
I tried to use UTF8, UTF16, ASCII to encode the response, however, the problem still remains.
UPDATED
My Http request works fine in graph explorer and postman, see below images.
However, when I tried to get the request with REQBIN which is an online request system, the result is not encoded, see below.
When I use unity to run this request with UnityWebRequest, the response is also not encoded. My C# code is as below,
UnityWebRequest www = UnityWebRequest.Get("api_link");
www.SetRequestHeader("Authorization", "Bearer " + getUserToken.userToken);
www.SetRequestHeader("Content-Type", "application/json");
yield return www.SendWebRequest();
Related
I am trying to get an access token via RestTemplate.postForEntity().
myRestTemplate.postForEntity(authBaseUrl, request, Object.class);
I have a specific class for it, but let's use now a simple Object as type. It contains an access_token field.
It works, because I can get response, but the length if the access tokens (which is a string)
is 1196 character long. And I can get the same length in Postman too.
But if I use the intelliJ built-in REST client, the length is 1199.
Only the token from the intelliJ rest client works (So the longer).
Because I always get a new access token, it is impossible to get the same token twice.
How can I debug it?
What could be the problem?
Is the code that generates the response available to you? if so in your response add a header content-length so you can see what the server sent and what you received. Also, debug the server side and see what is being generated. In addition take another 3d party Http client and test it with this client see if you see a difference. The Http clients that you can try are Apache Http client, OK Http client, or my favorite - a very simplistic client written by me as part of my own Open Source MgntUtils library. Here is the Javadoc for my http client Here is a link to a similar question where you can get the references for any of above mentioned Http clients: How to check the status of POST endpoint/url in java
I encounter {"result":560,"type":"exception"} response for axs request in jmeter while designing a script to do a load test for a mendix web application. First I encountered untheorized response on login so i used reg. expression extractor to extract CSRF-TOKEN and then login worked fine. after login and try to submit an application, i got {"result":560,"type":"exception"} response. what might be the issue and how can it be solved?
Response body
Response header
Request body
Request header
The issue is that you're sending an incorrect request. Unfortunately we cannot state what exactly is wrong because we need to see both:
Reference successful request including URL, headers and body from i.e. real browser
The request from JMeter which fails including URL, headers and body
So I can only suggest to use a 3rd-party sniffer tool like Wireshark or Fiddler to capture the requests from the real browser and JMeter and compare them. Request must be exactly the same (apart from dynamic parameters which need to be correlated). Given you send the same request as browser does you should get the same (successful) response
Other things to consider:
Check your server log, it might be the case you will figure out the reason from there like it was in this forum thread
Given you have Arabic characters in the request body ensure to use proper encoding, i.e. UTF-8 is always a good choice
I'm trying to communicate with Spotify using web API.
So here's the case. In order to retrieve any information from Spotify, first I need to be authorized by Spotify. To do so, I need to send a post request to https://accounts.spotify.com/api/token containing authorization credentials(containing client_id and client_secret), and then in response, I should receive an access token which later I shall use to retrieve any other information.
Here's a quick Spotify documentation on how it works :
So the problem here is that I'm doing everything I should but I don't get the token in response.
Here's my code using the Guzzle package in laravel :
And instead of an access token as a response, This HTML output is what I'm receiving from Spotify in return (Without any further information of the problem and any error code):
It is possible that you are misinterpreting this line?
Authorization: Basic <base64 encoded client_id:client_secret>
It looks like you are doing this:
base64_encode($client_id) . ":" . base64_encode($client_secret)
But perhaps they want this:
base64_encode($client_id . ":" . $client_secret);
That is, assuming you have base 64 encoded them at all as this is not actually shown in your code.
Additionally, the documentation states that it wants application/x-www-form-urlencoded encoding.
# Sending Form URL Encoded Requests
https://laravel.com/docs/8.x/http-client#sending-form-url-encoded-requests
To meet this requirement, it looks like you may need to add asForm() to the request.
$response = Http::withHeaders(...)->asForm()->post(...);
I'm working on a simple web browser project that uses QtWebEngine.
What I want to is to log out the httpRequest and httpResponse data that transit in my browser. I only interest in http POST transitions.
In chrome's developer's tool, I can do this by go to Network tab, turn on Preserve log. What I need is
Headers>General>Request URL
>From Data (params of POST)
Response (the raw response data)
Since QtWebEngine uses Chromium, I suppose that most things that chrome can do can also be done in QtWebEngine.
How can I get the above three things using QtWebEngine?
If there is no obvious way to do that, can I write an extension to log them out and make QtWebEngine use this extension? I think in extension I can log out http request header but I have no idea of how to log out the response data.
Edit: I don't want to an external debug tool (like port the log to localhost:myport). I need to use those three pieces of data in my browser application.
Edit2:
chrome.devtools.network.onRequestFinished.addListener
Yes somehow I need this but how can I call this or receive a similar event with Qt5.7?
I'm trying to make a httprequest from Parse.com cloud code, but although it returns response status code 200, it doesn't have any data with it (content-length: 0).
Because of my company privacy I can't post an URL on which the request fails, however it returns data successfully when used on http://www.seznam.cz/ or https://gmail.com/ (which returns 301 as a redirection issue, but still succeeds), so it's not caused by a https thing (my url is an api url with https)
Do you have an idea of why would the request succeed but return zero bytes, when in browser the data loads correctly?
Thanks!
It turned out that parse.com httpRequest doesn't use gzip decompression, and the api does, so although it received the response, nothing was returned since no data could be get.
I've overcome this issue by writing a php script posted on my web which get's the api's response, and prints it afterwards, therefore parse.com's httpRequest doesn't need to decompress the gzip and everything works as expected. I needed the same for images, by the way.