BodyMedia Forums

Bugs

RSS Feed

API request receives Error 596 Service Not Found

  1. We have successfully gotten to the point of having a non-empty access_token. However, every attempt we make to do API calls using that token result in Error 596 Service Not Found.

    We are using the OAuth ruby gem. We get the same error whether we attempts to do the API calls using the OAuth gem access token object or if we try to manually construct the URL and issue the GET from a browser. An example of the latter which generates this error is:

    http://api.bodymedia.com/body/current?api_key=<our API key>&oauth_consumer_key=<same as api_key>&oauth_nonce=eelVQOdIzA3wFDQ5r5vYbvbofmxOLfTQjYi5PdyEU&oauth_signature=<a signature>&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1309297382&oauth_version=1.0&oauth_token=<the token field from the access token after user authorization>

    The OAuth calls run in the ruby debugger which generate a valid access key but fail on get for an API call are:
    @consumer=OAuth::Consumer.new( "<our API key>",
    "<our secret>", {
    :site=>"https://api.bodymedia.com"
    })
    @token = @consumer.get_request_token
    puts "https://api.bodymedia.com/oauth/authorize?oauth_callback=http://localhost:3000&api_key=t6djaswzk2hg2p8q427s564ynkb3wpha&oauth_token=#{@token.token}"

    Manually browse to that URL, enter user name and password, click allow

    @access_token= @token.get_access_token()
    @headers = {"User-Agent" => "oauth gem", "Accept-Language" => "application/json"}
    @access_token.get("/body/current", @headers)

    Everything works except the last line, which returns #<Net::HTTPServerError 596 readbody=true>

    We notice that the OAuth gem is packaging most of the fields into a single request header field called "Authorization" which contains the following:
    OAuth oauth_consumer_key="<our API key>", oauth_nonce="bQShoQ80xmLD2QdCa2VdAg6dOAMzDW5U7DYLF4gHQ", oauth_signature="<a signature>", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1309298613", oauth_token="<the token field from the access token after user authorization>", oauth_version="1.0"

    Values in your logs may be different since we have to change the path in the @access_token.get call to use http instead of https in order to be able to see the request fields in HTTP Scoop (@access_token.get("http://api.bodymedia.com/body/current", @headers)). Some of the fields in the manually generated URL listed at the top was generated in this manner, splitting the "Authorization" header into URL parameters and with other fields edited in.

    We have also tried
    @access_token.get("/body/current?api_key=<our API key>", @headers)
    which also failed with the same error.

    Any suggestions how to get this to work?
    Thanks.

    Message edited by Anne Wright 3 years ago

  2. BodyMedia3 years ago

    Please make sure you are using the correct base URL. Instead of http://api.bodymedia.com/body/current try http://api.bodymedia.com/v1.0/body/current. I tested making calls to the correct URL using your key and secret combination and everything was working as expected. Let us know if you continue to have problems. Thanks.

  3. BodyMedia3 years ago

    One other problem we noticed is that you'll need to pass along the api_key as a request parameter with each call. Below are some examples. Hope this helps.

    @request_token=@consumer.get_request_token({}, :api_key => "abc1234-apikey")

    @access_token= @request_token.get_access_token({}, :api_key => "abc1234-apikey")

[ Page 1 of 1 ]