cancel
Showing results for 
Search instead for 
Did you mean: 

Creating entity in backend via Gateway using SUP not working

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Srinivas

  Sorry for the delayed reply,thanks that point helped me to move in right direction.

 

Regards

Santosh

Answers (0)