Welcome!

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

Reply
Regular Contributor
erAjayGoyal
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800

How to pass string value in the Header of QNetworkRequest?

Hi All, Need to pass string value in the header of QNetworkRequest. But there is no such function,they have provided only setRawHeader() & setHeader(). Kindly update me how to do that while using GET method in BB10.

 

Thanks & regards,

Ajay

Developer
simon_hain
Posts: 16,364
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to pass string value in the Header of QNetworkRequest?

what is wrong with setRawHeader?
----------------------------------------------------------
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
Regular Contributor
erAjayGoyal
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800

Re: How to pass string value in the Header of QNetworkRequest?

Actually setRawHeader() method takes only QbyteArray value but i want to pass QString value because on server side we have written code for String type header value.

Below code is working fine for BB 5,6,7 OS

 

HttpConnection connection = (HttpConnection) Connector.open(url + connectionParameters);

connection.setRequestMethod(HttpConnection.GET );
connection.setRequestProperty("Authorization", "OAuth " + Global.authToken);

 

Same work i want to do in BB 10.

 

Developer
Zmey
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to pass string value in the Header of QNetworkRequest?

You'll have to convert QString to QByteArray. QString is unicode, but UTF-8 should be sent over the network. HttpConnection seems to do this conversion internally.

QByteArray data = yourString.toUtf8();


Andrey Fidrya, @zmeyc on twitter
Regular Contributor
erAjayGoyal
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800

Re: How to pass string value in the Header of QNetworkRequest?

Same i am doing, Actually we need to change our server side code, problem on server side.