Sending parameters by get method to rest api
-
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.
-
wrote on 30 Jun 2022, 14:55 last edited by
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.
wrote on 30 Jun 2022, 15:10 last edited by ali-aydin@mchinand
this is token file{ "access_token": "1zVIXlpahfvS82xJEN2l2L7vPaUvX-AqHD5w_JmrSqHtV_hHdk6dKqdyFx6D62p1jPIcPPMdlVlsOlS4ZcoVUcsnrzTv8Ly42OLINofJYfdkVoitAQGdCzX7vYlnWBYNrxAOsMJiCdbjvONC2MftONA_hxhcsf8D3ax24buIupEkqPUoaBWUd6nx7HTx3Axo8ZdHZhM48SS68CczY-EDVUTDQSvYxv_4gQCxf_uWPuTrjTF2jwCbLfrCmhK7O_WJ07XmV-PYTj2jV7E35CpeFtx6W_FePFlhzim9qLv", "token_type": "bearer", "expires_in": 86399 }
-
wrote on 30 Jun 2022, 15:27 last edited by
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.
-
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.
-
wrote on 30 Jun 2022, 18:53 last edited by
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.
-
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.
wrote on 1 Jul 2022, 10:48 last edited by ali-aydin 7 Jan 2022, 10:58@mchinand
error body is :
Error transferring http://localhost:59444/api/Getmojodi?KalaCode=20101010131310 - server replied: Forbidden
and ststus code is :403
and hidden headers in postman :
-
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.
wrote on 1 Jul 2022, 11:50 last edited by ali-aydin 7 Jan 2022, 11:52@mchinand
@JonB
@SGaist
@Axel-Spoerl
Thank you everyone without your help I could not resolve that.
Thank you so much -
@mchinand
@JonB
@SGaist
@Axel-Spoerl
Thank you everyone without your help I could not resolve that.
Thank you so muchwrote on 1 Jul 2022, 11:54 last edited by@ali-aydin
this problem solution :
request must be in this shape :QUrl url("http://localhost:59444/api/Getmojodi"); request.setRawHeader(QByteArrayLiteral("Authorization"),token.toUtf8()); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); request.setRawHeader(QByteArrayLiteral("User-Agent"),"ApiTest2/1.0"); request.setRawHeader(QByteArrayLiteral("Accept"),"*/*"); request.setRawHeader(QByteArrayLiteral("Accept-Encoding"),"gzip, deflate, br"); request.setRawHeader(QByteArrayLiteral("Connection"),"keep-alive"); request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); QUrlQuery uq; uq.addQueryItem("KalaCode","20101010131310"); url.setQuery(uq); request.setUrl(url); manager->get(request);
-
The user agent is likely not needed in your case.
I think that you essentially need Content-Type and Accept-Encoding beside Authorization.
-
The user agent is likely not needed in your case.
I think that you essentially need Content-Type and Accept-Encoding beside Authorization.
37/40