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
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800
My Carrier: *

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
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

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
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800
My Carrier: *

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.

 

Highlighted
Developer
Posts: 1,524
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
Posts: 97
Registered: ‎04-19-2012
My Device: BB Torch-9800
My Carrier: *

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.