Skip to Content
author's profile photo Former Member
Former Member

Creating entity in backend via Gateway using SUP not working

Hi All

I am able to get the collection data from gateway oData using SUP libraries, but while creating entity using below code repeatedly it is giving http code:"400"

public void onClick(View v) {

Camptype_Text = Camp_Type.getText().toString();

MktOrg_Text = MktOrg.getText().toString();

Channel_Text =Channel.getText().toString();

String postURL = serviceDocPath

+ getIntent().getExtras().get("searchCategory");

TrialApp.getInstance().getLogger()

.i("InsertBooking", "Insert Rec: " + postURL);

String data =//"x-requested-with: XMLHttpRequest\r\n"

"\r\n"

+ "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n"

+ "<entry xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" xmlns=\"http://www.w3.org/2005/Atom\">\r\n"

+ "<content type=\"application/xml\">\r\n"

+ "<m:properties>\r\n"

+ "<d:campType>Z021</d:campType>\r\n"

+ "<d:mktOrg>50000027</d:mktOrg>\r\n"

+ "<d:channel>ZPHN</d:channel>\r\n"

+ "</m:properties>\r\n"

+"</content>\r\n"

+ "</entry>";

ISDMRequest postRequest = TrialApp.buildRequest(postURL, self);

Map<String, String> headers = new HashMap<String, String>();

headers.put("X-Requested-With", "XMLHttpRequest");

//headers.put("Content-Type", "application/xml");

((SDMBaseRequest) postRequest).setHeaders(headers);

final byte[] theByteArray = data.getBytes();

((SDMBaseRequest) postRequest).setData(theByteArray);

postRequest.setRequestMethod(ISDMRequest.REQUEST_METHOD_POST);

TrialApp.getInstance().getRequestmanager()

.makeRequest(postRequest);

}

Am I doing wrong any where ,Request for help in resolving the issue.sh

Thanks

Santosh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 03, 2012 at 05:01 AM

    Hi Santosh,

    problem is String data =//"x-requested-with: XMLHttpRequest\r\n"

    this might be leading to malformed xml, you need to add this XMLHttpRequest in the header while creating a POST request.

    Regards,

    Srinivas Divakarla

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.