I’m working with an EF data model which is exposed through an OData service endpoint. It has Person and Group entities which are connected through a many-to-many relationship.

I would like to add a link from an existing Person with an existing Group through OData, but I have been unable to figure out how. The OData protocol as specified here (link to odata.org) seems to specify that I need to do the following HTTP request to link Person #1 to Group #1:
- Method: POST
- URI: “http://localhost:49432/MyService.svc/Persons(1)/$links/Groups”
With the body as follows:
{
__count: 1,
results: [{
uri: "http://localhost:49432/MyService.svc/Groups(1)"
}]
}
However, when I do that, I get the following error:
400 Bad Request
"Missing URI element. For link operations, URI element must be specified."
I have no idea what URI element is missing. I have provided that in both the request URI and in the payload…
I have also tried several other approaches, but no success so far. Any suggestions?
Thanks!
If you want to do more than one link, here’s how you do it:
Payload should look something like this:
Hope this helps.
Thanks
Pratik