Sending parameters by get method to rest api
-
@Axel-Spoerl
Yes I tried by postman and is ok -
@Axel-Spoerl
Yes I tried by postman and is ok@ali-aydin
Your platform/web server may/should have the ability to log all requests/responses to a log file? You might switch that on and see if anything helpful there? -
@ali-aydin
Your platform/web server may/should have the ability to log all requests/responses to a log file? You might switch that on and see if anything helpful there? -
@ali-aydin Look in your web server's documentation.
-
@ali-aydin Look in your web server's documentation.
-
I think you have to add 'Basic ' before your token when you set the Authorization header (or 'Bearer ' if you are doing bearer token auth). If things are working in Postman, check the 'Headers' tab of your request as to what is the actual value being sent for the Authorization.
-
I think you have to add 'Basic ' before your token when you set the Authorization header (or 'Bearer ' if you are doing bearer token auth). If things are working in Postman, check the 'Headers' tab of your request as to what is the actual value being sent for the Authorization.
@mchinand
Bearer must be added to the token.
in postman there is no header
in authorization tab
only added token and in parameters tab is only one parameter :KalaCode
in body tab username,password and grant_type
in the qt when I want to authenticate byQUrl url("http://localhost:594444/api/authenticate");
it returns "Hello"
but when i changing url toQUrl url("http://localhost:594444/api/Getmojodi" );
it does not work
-
I meant the 'Headers' tab of the Postman request:
The authorization header value above was automatically set when I added a (junk) username and password in the Auth tab:
-
Are you setting the Authorization the same in Qt as the value it is set in Postman? Your variables are 'basic_authorization' and 'token', is token just the token or is the token type prepended to it ('Basic ' or 'Bearer ')? Your variable is 'basic_authorization' but in your prior message, you mention adding 'Bearer' before the token, which auth method are you using?
-
Are you setting the Authorization the same in Qt as the value it is set in Postman? Your variables are 'basic_authorization' and 'token', is token just the token or is the token type prepended to it ('Basic ' or 'Bearer ')? Your variable is 'basic_authorization' but in your prior message, you mention adding 'Bearer' before the token, which auth method are you using?
-
@mchinand
i'm using url.setRawHeader() for add token to url and
and adding bearer to token
i don't use any auth method
how to use that? -
Are you doing Basic (username/password) or Bearer Token? What method are you selecting in Postman? What is the value of your token variable, post the string but modify the actual token part.
-
What is the value of your token variable, post the string but modify the actual token part.
@mchinand
this is token file{ "access_token": "1zVIXlpahfvS82xJEN2l2L7vPaUvX-AqHD5w_JmrSqHtV_hHdk6dKqdyFx6D62p1jPIcPPMdlVlsOlS4ZcoVUcsnrzTv8Ly42OLINofJYfdkVoitAQGdCzX7vYlnWBYNrxAOsMJiCdbjvONC2MftONA_hxhcsf8D3ax24buIupEkqPUoaBWUd6nx7HTx3Axo8ZdHZhM48SS68CczY-EDVUTDQSvYxv_4gQCxf_uWPuTrjTF2jwCbLfrCmhK7O_WJ07XmV-PYTj2jV7E35CpeFtx6W_FePFlhzim9qLv", "token_type": "bearer", "expires_in": 86399 }
-
Try
QString token = <access_token from file> token.prepend("Bearer "); req1.setRawHeader(QByteArrayLiteral("Authorization"), token.toUtf8());
I don't think you want the 'toBase64()' that you have in your code above.
-
Check the request sent by postman and the one from your application and compare for differences.
-
Check the request sent by postman and the one from your application and compare for differences.
-
Be sure to compare the url, body, and header (also, be sure to look at the auto-generated headers in Postman which are hidden by default). Are you extracting the token correctly from your file? Have you debugged that part of your code? You did not include that with your original post.