Skip to Content
0
Former Member
May 02, 2012 at 01:14 PM

Creating entity in backend via Gateway using SUP not working

19 Views

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