Project

General

Profile

Is this a valid Xml request?

Added by Michael Knight over 4 years ago

I have not much experience with Xml and I want to know if this is a valid Xml request using Wt3:

@ Http::Message msg1;

msg1.addHeader("Authorization","720ddc067f4d115bd544aff46b......");

msg1.addHeader("SecretKey", "21EC2020-3AEA-1069~~....~~...........");

msg1.addHeader("Content-Type", "application/xml");

msg1.addHeader("Accept", "application/xml");

msg1.addHeader("Content-Length","0");

msg1.addBodyText(""

"1"

"A006testitem201201021459"

""

"USA"

"AUS"

"");

if (client->request(mt,"https://api.newegg.com/marketplace/contentmgmt/item/international/price?sellerid={SellerID}",msg1))

{

...@

Using this code returns "403" from newegg server, so I think it means that the server understands my request but it is denying to authorize(I got some of the code (it was an example from newegg developers' website, including authorization code and secretkey so it seems normal that it doesn't authorize).

So I just want to know if my code is valid and if it is not, could you give an example for valid Xml request.


Replies (5)

RE: Is this a valid Xml request? - Added by Michael Knight over 4 years ago

Http::Method mt= Http::Put;

Add this code to the top.

RE: Is this a valid Xml request? - Added by Michael Knight over 4 years ago

"

_Http::Method mt= Http::Put;

Http::Message msg1;

msg1.addHeader("Authorization","720ddc067f4d115bd544aff46bc75634");

msg1.addHeader("SecretKey", "21EC2020-3AEA-1069-A2DD-08002B30309D");

msg1.addHeader("Content-Type", "application/xml");

msg1.addHeader("Accept", "application/xml");

msg1.addHeader("Content-Length","0\");

msg1.addBodyText(""

"1"

"A006testitem201201021459"

""

"USA"

"AUS"

"");

client->request(mt,"https://api.newegg.com/marketplace/contentmgmt/item/international/price?sellerid

{SellerID}",msg1)

{_

\"

RE: Is this a valid Xml request? - Added by Michael Knight over 4 years ago

Delete the '' and '_' from code of course, I wrongly wrote them.

RE: Is this a valid Xml request? - Added by Roel Standaert over 4 years ago

This looks kind of suspicious:

 msg1.addHeader("Content-Length","0");

You're setting the content length to 0 but also sending body data? You should omit the Content-Length header, and let Wt set it for you.

Also, it doesn't look like you're sending proper XML, since you're opening the <ContentQueryCriteria>, but not closing it.

RE: Is this a valid Xml request? - Added by Michael Knight over 4 years ago

Thanks for your answer.

I had tried to make request without using Content-Length header and it had given an error(on console windows) related to Content-Length not set.Though I think probably I had done another error that time because after reading your message I deleted Content-Length header and made the request, it didn't give that error this time.

About not closing the tag,yes it escaped from my attention.

Thanks

    (1-5/5)