Coder Social home page Coder Social logo

Create customer failing? about desk HOT 9 CLOSED

chriswarren avatar chriswarren commented on September 26, 2024
Create customer failing?

from desk.

Comments (9)

chriswarren avatar chriswarren commented on September 26, 2024

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:
400

Is 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.

mbhnyc avatar mbhnyc commented on September 26, 2024

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.

mbhnyc avatar mbhnyc commented on September 26, 2024

Any ideas on this? Are there required attributes that I can't find documentation for anywhere or something?

from desk.

chriswarren avatar chriswarren commented on September 26, 2024

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.

mbhnyc avatar mbhnyc commented on September 26, 2024

Here it is:

https://www.runscope.com/public/b3dac376-b840-4019-9668-c94412bbe625/7403fa35-edd6-408d-8ae8-f523b0194810

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.

chriswarren avatar chriswarren commented on September 26, 2024

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:

https://www.runscope.com/public/b3dac376-b840-4019-9668-c94412bbe625/7403fa35-edd6-408d-8ae8-f523b0194810

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:inblock 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:incall'
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:incall'
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:incall'
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:inpost'
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:inpost'
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:inmethod_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:instart'
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:inrequire'
from script/rails:6:in `

'irb(main):002:0>


Reply to this email directly or view it on GitHubhttps://github.com//issues/25#issuecomment-21007771
.

from desk.

mbhnyc avatar mbhnyc commented on September 26, 2024

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.

chriswarren avatar chriswarren commented on September 26, 2024

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.

mbhnyc avatar mbhnyc commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.