Comments (9)
That should work fine as far as I know - is there any message in the
response body with an error message that'd indicate what they didn't like
about the request?
On Fri, Jul 12, 2013 at 12:08 PM, mbhnyc [email protected] wrote:
Hey guys,
So trying a simple customer create:
Desk.create_customer(first_name: "Matt", last_name: "Person")
Fails with:
Desk::BadRequest: POST https://soundstreak.desk.com/api/v2/customers.json:
400Is there an API change that needs to be applied?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/25
.
from desk.
Sadly no, beyond that all I get is the exception message, is there a way to display the raw response from the API? Hrm
from desk.
Any ideas on this? Are there required attributes that I can't find documentation for anywhere or something?
from desk.
Can you try running the request through Runscope (http://runscope.com) and share the request with me? Feel free to send it in a message so your keys aren't exposed here, and we'll update with whatever we find.
from desk.
Here it is:
Note the keys are in there, but i'll just regenerate them after this is closed out.
Long story short, call was successful!
For the record, tried it again via the ruby console:
Desk::BadRequest: POST https://soundstreak.desk.com/api/v2/customers.json: 400
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/faraday/response/raise_http_4xx.rb:10:in `on_complete'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:9:in `block in call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:63:in `on_complete'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/request/url_encoded.rb:14:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/request/multipart.rb:13:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday_middleware-0.9.0/lib/faraday_middleware/request/oauth.rb:42:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/faraday/request/multipart_with_file.rb:16:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:247:in `run_request'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:112:in `post'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/request.rb:43:in `request'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/request.rb:11:in `post'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/client/customer.rb:43:in `create_customer'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk.rb:25:in `method_missing'
from (irb):1
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):002:0>
from desk.
Are you trying it the same way through Runscope as you are when it fails?
On Mon, Jul 15, 2013 at 3:10 PM, mbhnyc [email protected] wrote:
Here it is:
Note the keys are in there, but i'll just regenerate them after this is
closed out.Long story short, call was successful!
For the record, tried it again via the ruby console:
Desk::BadRequest: POST https://soundstreak.desk.com/api/v2/customers.json
'irb(main):002:0>
: 400
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/faraday/response/raise_http_4xx.rb:10:inon_complete' from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:9:in
block in call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:63:inon_complete' from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/response.rb:8:in
call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/request/url_encoded.rb:14:incall' from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/request/multipart.rb:13:in
call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday_middleware-0.9.0/lib/faraday_middleware/request/oauth.rb:42:incall' from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/faraday/request/multipart_with_file.rb:16:in
call'
from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:247:inrun_request' from /app/vendor/bundle/ruby/2.0.0/gems/faraday-0.8.7/lib/faraday/connection.rb:112:in
post'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/request.rb:43:inrequest' from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/request.rb:11:in
post'
from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk/client/customer.rb:43:increate_customer' from /app/vendor/bundle/ruby/2.0.0/gems/desk-0.3.3/lib/desk.rb:25:in
method_missing'
from (irb):1
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/console.rb:47:instart' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in
start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:41:in<top (required)>' from script/rails:6:in
require'
from script/rails:6:in `—
Reply to this email directly or view it on GitHubhttps://github.com//issues/25#issuecomment-21007771
.
from desk.
Well, none of the credentials are different, if that's what you mean. I'm not running the request from the rails API via the bare API, i'm using the gem's built in methods...
Here's my desk.rb initializer:
Desk.configure do |config|
config.support_email = "[email protected]"
config.subdomain = "xxx"
config.consumer_key = "xxx"
config.consumer_secret = "sss"
config.oauth_token = ENV['DESK_OAUTH_TOKEN']
config.oauth_token_secret = ENV['DESK_OAUTH_TOKEN_SECRET']
config.version = "v2"
end
And then I just run the command as shown above.
from desk.
Yes, but something is different between making the request with the gem and with something else (like curl) to Runscope, so testing them the same way would be helpful in figuring out what's going wrong. It's more likely that something changed between v1 and v2 or that something is wrong with the gem than that their documentation is wrong about the required fields.
I did a quick test using the gem and Runscope and the response from Desk.com says that the JSON is invalid. Inspecting the body of the request it's definitely not JSON, it's a form encoded POST. They must've supported that in v1 but don't in v2. It's been a while, I don't recall why it's set up that way, unfortunately.
@colinc was working on migrating the gem over to v2, but I'm not sure how far along he is right now. You could use v1 in the meantime, you can wait for the gem to be updated and tested against V2, or you could look in to patching this (which would be awesome). Sorry I don't have a simpler solution right now.
from desk.
That'll do it! Interesting choice on Desk's part — it's the first time I've seen this as a requirement from a public facing API. Is this the new de rigeur??
from desk.
Related Issues (20)
- Copy-paste errors in ratelimit_remaining
- Faraday parsing errors even after #31 HOT 12
- Please update faraday dependency / conflicts with google oauth2 HOT 1
- gem "hashie" issue HOT 7
- Search case by order_no HOT 7
- collections only respond to each instead of all of Enumerable HOT 4
- Raise Desk-namespaced exceptions for other non-200 responses
- 422 error response not parsed correctly HOT 5
- Faraday::ParsingError: 757: unexpected token at 'Too Many Requests' HOT 1
- Desk.com gem ignores client config? HOT 2
- Desk.delete_case is not working HOT 3
- Logger does not log request and response body
- Document how to log request and response
- RuntimeError: missing dependency for FaradayMiddleware::Deashify: undefined method `type' for class `Hashie::Mash' HOT 9
- Incorrect from/reply_to address
- Configuration Issue
- Desk.insights_meta produces a 404 HOT 2
- Problem with the Thread.current in the Configuration HOT 1
- Bug when creating articles HOT 1
- Hashie fixed version giving conflicts HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from desk.