Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while try excecute update_object and save_changes #14

Open
jdcrackdon opened this issue May 15, 2012 · 9 comments
Open

Error while try excecute update_object and save_changes #14

jdcrackdon opened this issue May 15, 2012 · 9 comments
Labels

Comments

@jdcrackdon
Copy link

Hi dude i have this code

svc = OData::Service.new "http://dev.idlinksolutions.com/clicktoaction/clicktoactionData.svc/" , { :username => "xxxxxxxxx", :password=> "xxxxxx" }

svc.FanPages.filter("PageId eq '#{settings.fan_page_id}'")
fan_page = svc.execute.first

fan_page.Token = 'aaa'

svc.update_object(fan_page)
result2 = svc.save_changes

p result2.inspect

But, this say Bad request 400 error

@visoft
Copy link
Owner

visoft commented May 15, 2012

Which part gives you a 400 error, the query portion of the update?

@jdcrackdon
Copy link
Author

result2 = svc.save_changes, in this line

@visoft
Copy link
Owner

visoft commented May 16, 2012

Try using the develop branch of ruby_odata. I added some basic error handling so you should be able to see the cause of your 400 error. It should spit out a more useful message (pulled from the error xml returned from the OData service) when the exception is thrown. Let me know what you find...

@jdcrackdon
Copy link
Author

Dude, look this is my error with the develop branch, i can not understand this: 2012-05-16T13:26:55+00:00 app[web.1]: RuntimeError - HTTP Error 400: Only 'If-Match' headers are supported for Update/Delete operations.:

i whan update a deatil table with a master. my table has a foreign key

@visoft
Copy link
Owner

visoft commented May 16, 2012

Is your OData Service using etags? I think it's a problem with concurrency management (scroll down to the section Concurrency Management here http://msdn.microsoft.com/en-us/library/ff798339.aspx). I'm not doing anything with passing etags around, so my guess is that the entity you are trying to update doesn't match the current entity.

@jdcrackdon
Copy link
Author

yes, i think this is the problem merge concurrency, with the etags.

@bronaghs
Copy link

Hi -
I've been stuck on the same problem for a few days.
Can you share some code to illustrate how I can resolve this? From the link in the earlier post above it looks like I need to either:

  1. set the X-HTTP-Method header
    or
  2. indicate an ETag in the If-Match HTTP request header.

Im not sure how to do either on the odata service object. Here is my code:

svc_vm = OData::Service.new "https://server:8090/SC2012R2/vmm/Microsoft.Management.Odata.svc/", {:verify_ssl => false, :username => "user", :password => "password", :namespace => "VMM"}

svc_vm.VirtualMachines.Filter("Name eq 'LinuxVM'")
vms = svc_vm.execute
vm = vms.first
vm.Operation = "Start"
svc_vm.update_object(vm)
result = svc_vm.save_changes

thanks in advance for any help.

@visoft
Copy link
Owner

visoft commented Nov 20, 2013

I haven't added support for etags, because I'm not sure how to set them up for an OData service. If you can figure it out and could supply sample data of returned results (edmx, and query results), then it should be something that ruby_odata could support.

@bronaghs
Copy link

@jdcrackdon - Do you have some some sample code? i'm really stuck with this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants