0

I am trying to create links b/w Products(ID =1 and ID =2) and Category(ID=12) using the OData service- http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Categories(12)/$links/Products

using the payload:

<?xml version="1.0" encoding="utf-8"?>
<links xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
<uri>http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Products(7)</uri>
<uri>http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Products(8)</uri>
</links>

But I am getting an 400 bad request error:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-US">Missing URI element. For link operations, URI element must be specified.

Any suggestion?? Am I doing something wrong here??

Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29
user3201181
  • 62
  • 1
  • 9

1 Answers1

0

First of all, for the error message you got, the reason is that your request body payload is not right. The request body should look like

<?xml version="1.0" encoding="utf-8"?>
<uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Products(6)
</uri>

And second, I also think that maybe it not support 1 to many carnality in this situation. But if you want to add two in one time, maybe you can try with the batch request http://www.odata.org/documentation/odata-version-2-0/batch-processing/

QianLi
  • 1,088
  • 12
  • 22