UpdateEntity with rebinding link
- In the APDSU spec 2.2.7.3.1 UpdateEntity Request section, it says the user can rebind the link using the UpdateEntity request.
I am trying to rebind the link of Territories('60001') to region to Region(7001), but it doesn't works. When I issue a get entity request, the Region associated with the Territories('60001') is still Region(6001).
Here is my put request.
PUT //NorthwindWeb/NorthwindDataService.svc/Territories('60001') HTTP/1.1
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://host:port/NorthwindWeb/NorthwindDataService.svc/" 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">
<category term="NorthwindModel.Territories" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
<content type="application/xml">
<m:properties>
<d:TerritoryDescription xml:space="preserve">Territory 003 </d:TerritoryDescription>
<d:TerritoryID>60001</d:TerritoryID>
</m:properties>
</content>
</entry>
Did I miss something? Thanks.
Answers
Can you please try changing the rel attribute value on the link element to "http://schemas.microsoft.com/ado/2007/08/dataservices/related/BestFriend"? In other words the payload should look something like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://host:port/NorthwindWeb/NorthwindDataService.svc/" 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">
<category term="NorthwindModel.Territories" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
<content type="application/xml">
<m:properties>
<d:TerritoryDescription xml:space="preserve">Territory 003 </d:TerritoryDescription>
<d:TerritoryID>60001</d:TerritoryID>
</m:properties>
</content>
</entry>
Hope this helps.
Thanks
Pratik
This posting is provided "AS IS" with no warranties, and confers no rights.- Unmarked As Answer byPratik Patel - MSFTModeratorMonday, September 28, 2009 8:47 PM
- Marked As Answer byPratik Patel - MSFTModeratorMonday, September 21, 2009 7:59 PM
- Marked As Answer byPratik Patel - MSFTModeratorMonday, October 19, 2009 5:44 PM
All Replies
Can you please try changing the rel attribute value on the link element to "http://schemas.microsoft.com/ado/2007/08/dataservices/related/BestFriend"? In other words the payload should look something like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://host:port/NorthwindWeb/NorthwindDataService.svc/" 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">
<category term="NorthwindModel.Territories" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
<content type="application/xml">
<m:properties>
<d:TerritoryDescription xml:space="preserve">Territory 003 </d:TerritoryDescription>
<d:TerritoryID>60001</d:TerritoryID>
</m:properties>
</content>
</entry>
Hope this helps.
Thanks
Pratik
This posting is provided "AS IS" with no warranties, and confers no rights.- Unmarked As Answer byPratik Patel - MSFTModeratorMonday, September 28, 2009 8:47 PM
- Marked As Answer byPratik Patel - MSFTModeratorMonday, September 21, 2009 7:59 PM
- Marked As Answer byPratik Patel - MSFTModeratorMonday, October 19, 2009 5:44 PM
- Hi Pratik,
Here is what I tried with different link syntax:
1) <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
This gives me 400 error with the following message:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">An error occurred while processing this request.</message>
</error>
2) <link rel="http://schemas.microsoft.com/ado/2007/08/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
This gives me response code 204. However, the Territories is not rebound to Region(7001).
3) <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
This is same ast 2), it gives me response code 204. However, the Territories is not rebound to Region(7001).
- Can you turn on the error to see what's the exact error you are encountering in the first case? Here's the blog which tells you how to do this: http://blogs.msdn.com/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx
Once you have a detailed error, it will help me figure out the exact issue.
Thanks
Pratik
This posting is provided "AS IS" with no warranties, and confers no rights. - We have already set config.UseVerboseErrors = true; in our svc.
As I described above, there is no inner error in the error response, just
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">An error occurred while processing this request.</message>
</error>
If I use <link rel="http://schemas.microsoft.com/ado/2007/08/related/Region" href="http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)"/>
This gives me response code 204. However, the Territories is not rebound to Region(7001). If you do not specify the right attribute value for the 'rel' attribute, we ignore the link element. That's the reason why in the 2nd and 3rd cases, you are seeing 204, but the link is not getting re-binded. That's by design.
Now coming back to the error message issue, i can't think of anything else - after changing the config, did you re-compile and re-deploy your application? If you are hosting in IIS, you might want to recycle IIS and see if that helps. Without the error message, its hard to tell what's the error happening on the server.
This posting is provided "AS IS" with no warranties, and confers no rights.- If I do some other operations in a wrong way, I can get error with an inner error. Could be that this error doesn't have inner error?
Can you try to do something else to see if Re-binding works - try the following PUT request
<uri xmlns='http://schemas.microsoft.com/ado/2007/08/dataservices'>http://host:port/NorthwindWeb/NorthwindDataService.svc/Region(7001)</uri>
PUT //NorthwindWeb/NorthwindDataService.svc/Territories('60001')/$links/Region
Please let me know how this goes? If this works, then rebinding works, but there is something else wrong with our earlier PUT request.
Thanks
Pratik
This posting is provided "AS IS" with no warranties, and confers no rights.- Yes, updateLink directory using PUT //NorthwindWeb/NorthwindDataService.svc/Territories('60001')/$links/Region works. Thanks!
- For the following comment, can you double check and confirm it is a bug in ADO.NET service?
"If this works, then rebinding works, but there is something else wrong with our earlier PUT request."
Thanks!


