0

Odata is a new thing for me and I'm trying getting in deep with it. So I'm trying insert data using OData protocol in atom format and using a rest client. So I've created the following http Post request:

POST /HelloOdata/library.xsodata/books HTTP/1.1
Host: coe-he-55:8010
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
DataServiceVersion: 1.0
MaxDataServiceVersion: 2.0
accept: application/atom+xml
Content-Type: application/atom+xml
Cache-Control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?xml version="1.0" encoding="utf-8"?> 
<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">
  <title type="text">books</title> 
  <author> 
    <name /> 
  </author>
        <link href="books('Test_post')/Author" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" title="Author" type="application/atom+xml;type=entry"/>
  <category term="HelloOdata.library.booksType"
      scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
  <content type="application/xml"> 
    <m:properties> 
      <d:title>Test_post</d:title>
      <d:ISBN>ISBN_POST</d:ISBN>
      <d:editions>2</d:editions>
    </m:properties> 
  </content> 
</Entry>

and as a response I've got: The serialized resource has an missing value for member 'title'.

Well my table books has only three properties which are title, ISBN and editions precisely those one I'm trying insert through this statement. So, do you have any idea what can be wrong in it?

Thank you Pablo

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Pablo Silva
  • 47
  • 10

1 Answers1

0

I've found where the error was. Unbelievably the right xml request is:

POST /HelloOdata/library.xsodata/books HTTP/1.1
Host: coe-he-55:8010
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
DataServiceVersion: 1.0
MaxDataServiceVersion: 2.0
accept: application/atom+xml
Content-Type: application/atom+xml
Cache-Control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?xml version="1.0" encoding="utf-8"?> 
<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">
  <title type="text">books</title> 
  <author> 
    <name /> 
  </author>
  <category term="HelloOdata.library.booksType"
      scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
  <content type="application/xml"> 
    <m:properties> 
      <d:title>Test_post</d:title>
      <d:ISBN>ISBN_POST</d:ISBN>
      <d:editions>2</d:editions>
    </m:properties> 
  </content> 
</entry>

well I also had to get off with this part:

 <link href="books('Test_post')/Author" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" title="Author" type="application/atom+xml;type=entry"/>

but this was an attempt after the first one, because the real problem was the tag

<Entry> 

write with E and not

<entry>

Once I changed it, the Http request works well.

I saw this example of insertion of data with OData on the official website guideline: http://www.odata.org/documentation/odata-version-2-0/operations and there the tag entry was written with capital letter.

Thank you! Pablo

Pablo Silva
  • 47
  • 10