Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8493

Creating a new entry dynamically using OData - Android

$
0
0

Hi,

 

I am developing a sample android project to perform CRUD opertaions using OData services. In this I am facing an issue in building an xml using inbuit APIs. Please find below my query.

 

I am able to successfully create a new entry by using the POST request. But, in this method i am passing the hardcoded entity xml in the POST body of the request. As i feel this is not an optimized way, Are there any APIs associated with creating an entry where I can just pass the new values instead of passing the entire xml structure.

 

PFB my code:

 

String createXml = "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><title type=\"text\">CUSTOMER</title><updated>2014-01-23T12:48:00.009+05:30</updated><category term=\"Service.CustomerObj\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\"/><content type=\"application/xml\"><m:properties><d:CUSTID>"
    + "3"
    + "</d:CUSTID><d:LASTNAME>"
    + "jeeri"
    + "</d:LASTNAME><d:FIRSTNAME>"
    + "Nvn"
    + "</d:FIRSTNAME><d:ADDRESS>"
    + "xyz"
    + "</d:ADDRESS><d:CITY>"
    + "abc"+ "</d:CITY></m:properties></content></entry>";

 

BaseRequest request = new BaseRequest();
request.setListener(this);
request.setRequestUrl(url); // Collection URL
request.setRequestMethod(IRequest.REQUEST_METHOD_POST);
Map<String, String> headers = new HashMap<String, String>();
headers.put("content-type", "application/atom+xml");
request.setHeaders(headers);
request.setData(createXml.getBytes()); 
reqManagerObject.makeRequest(request);

 

I am looking for an API where if I pass the entry object that contains CUSTID, LASTNAME, FIRSTNAME, ADDRESS and CITY it would build the xml automatically.

 

Thanks in advance,

Naveen



Viewing all articles
Browse latest Browse all 8493

Trending Articles