Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 259
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil
Accepted Solution

QNetworkAccessManager and problem with header

I'm having some issues with authentication.

According to imgur documentation you only need to use the following for anonymous usage:


Authorization: Client-ID YOUR_CLIENT_ID

 Which worked well when I was in QML, I simply used the following with XMLHttpRequest

xmlhttp.setRequestHeader("Authorization", "Client-ID myclientid...");

 Now I'm trying to upload image inside c++, and am getting authentication error. I tried several things including

QNetworkAccessManager* netManager = new QNetworkAccessManager();
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart authPart;
authPart.setRawHeader("Authorization","Client-ID myclientid..");
QNetworkReply* ipReply = netManager->post(req, multiPart);

 And I'm not quite sure what I'm doing wrong, but it just won't stop returning this

{"data":{"error":"Authentication required","request":"\/3\/upload","method":"POST"},"success":false,"status":401}


Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: QNetworkAccessManager and problem with header

i would suggest to set the raw header on the request
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 161
Registered: ‎01-03-2013
My Device: n/a
My Carrier: n/a

Re: QNetworkAccessManager and problem with header

On the c++ side listen to the QNetworkAccessManager's authenticationRequired signal and fill in the QAuthenticator that is sent.


If my answer has been useful to you, please, click the button
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: QNetworkAccessManager and problem with header

Just use setRawHeader as suggested simon_hain .

This is what i use for my QtC++ Imgur library

QNetworkRequest request;
request.setRawHeader("Authorization",  "Client-ID YOU_CLIENT_ID");


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Posts: 259
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil

Re: QNetworkAccessManager and problem with header

Thanks, that solved the problem. You guys are awesome