+ Start a Discussion
VKSINGHVKSINGH 

sending xml data from salesforce to external server using http post request (Restful API).

hi every one, need ur help

 

When i m sending the hard code xml data through http,in response i m getting the status is ok n status code is 200,but the xml data is going to the external server in some encoded form.I m not using any encoding(like UTF-8) in my code,but still the external server getting xml in encoded form. 

 

Can any one tell me,how to remove this problm,cos if the external server receives the correct xml format data it will response back to correct value,for which i m looking.

 

Best Answer chosen by Admin (Salesforce Developers) 
SimonJaiSimonJai

I'm not actually sure, but I'll take a guess and assume it's becuase the data you are sending is compressed it?

All Answers

SimonJaiSimonJai

I'm not actually sure, but I'll take a guess and assume it's becuase the data you are sending is compressed it?

This was selected as the best answer
VKSINGHVKSINGH

yes simon u r right,

 

i found that error, n i already fixed it,yes it is bcs of i m doing compression.

 

but, Thanx for u rply..:)

 

i have another problm now,i m sending hard code xml here,but i have to generate xml dynamically,could u hepl me how to do that n what changes i have to made in my code.

 

Thanx in advance

sami amisami ami
Hi..I am in the same issue.How did you do that?
Can you please post your final code here...please.
Amritesh SinghAmritesh Singh

hey i am same VKSingh.

 

Now where r u geeting error n what ?

 

above code works fine for sending xml through to an end point.

only remove this line : req.setCompressed(true); 

 

 

let me know if u have any prblm 

sami amisami ami
No singh...I am not getting any error.I am not using compressed also.My question was how did you send xml data?
I hardcoded and tested.It works.Now want to make it dynamic.I am working on std object account.Account should be created in my third party tool when type is customer.Rest cases it shouldnt.
how can i do this??

Thank you
sami amisami ami
I figured it.
I should use xmlstreamwriter.Thanks
Amritesh SinghAmritesh Singh

Yes..XmlStreamwrite. to generate dynamic xml and send it to http post.