You need to sign in to do that
Don't have an account?

UNSUPPORTED_MEDIA_TYPE with Ruby and REST API using POST
I started out with Quinton's article here and am trying to build out some samples using Rails and the REST API. I can query for and fetch records but am having problems creating new records.
Here's my code:
def self.create() Accounts.set_headers options = { :body => { :Name => "TestRailsApp" } } response = post(Accounts.root_url+"/sobjects/Account/", options) puts response.body, response.code, response.message end
But I am getting the following response back:
opening connection to na5.salesforce.com... opened <- "POST /services/data/v21.0/sobjects/Account/ HTTP/1.1\r\nAuthorization: OAuth 00D700000009Bki!ARQAQHsUMNBjZTLupOGjYhGDQ9k8SN0FC9qGnVMhpM5rqgLsOBPVhgtsgwqYzELkcX47FlyqQhGAf83eaXXXXX\r\nConnection: close\r\nHost: na5.salesforce.com\r\nContent-Length: 8\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n" <- "Name=TestRailsApp" -> "HTTP/1.1 415 Unsupported Media Type\r\n" -> "Server: \r\n" -> "Content-Type: application/json; charset=UTF-8\r\n" -> "Content-Length: 135\r\n" -> "Date: Tue, 26 Apr 2011 14:15:34 GMT\r\n" -> "Connection: close\r\n" -> "\r\n" reading 135 bytes... -> "[{\"message\":\"MediaType of 'application/x-www-form-urlencoded' is not supported by this resource\",\"errorCode\":\"UNSUPPORTED_MEDIA_TYPE\"}]" read 135 bytes Conn close [{"message":"MediaType of 'application/x-www-form-urlencoded' is not supported by this resource","errorCode":"UNSUPPORTED_MEDIA_TYPE"}] 415 Unsupported Media Type
Any ideas? Thanks!
Jeff Douglas
Appirio, Inc.
That did the trick Simon!! Thanks for the help. Here' s my solution:
Jeff Douglas
Appirio, Inc.
http://blog.jeffdouglas.com
http://www.cloudspokes.com
All Answers
You're sending an HTML form as the post payload, it needs to be an xml or json document instead.
That did the trick Simon!! Thanks for the help. Here' s my solution:
Jeff Douglas
Appirio, Inc.
http://blog.jeffdouglas.com
http://www.cloudspokes.com