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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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: 17,026
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.

 

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.