price api responding with 401

Discussion in 'Shapeways API' started by 597867_deleted, Aug 20, 2014.

  1. I have implemented much of the api in java using jersey however the price api is responding with a 401.
    I successfully get materials, printers and models.
    For the price api I'm reusing the same oauth 1.0 parameter settings as the above gets and adding
    the price post parameters.
    Here is a printout of the parameters (replaced consumer key with <my consumer key>):
    Params: {xBoundMax=0.01, oauth_nonce=1408514012058, oauth_version=1.0, oauth_consumer_key=<my consumer key>, oauth_signature=signature, area=0.0006, zBoundMin=0.01, oauth_signature_method=HMAC-SHA1, oauth_token=41489a1ed330bfcd02c5fa28cf474a8d138b6241, volume=0.000001, yBoundMax=0.01, yBoundMin=0.01, oauth_timestamp=1408514040, xBoundMin=0.01}
    This is the response:
    Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: POST https://api.shapeways.com/price/v1 returned a response status of 401
    at com.sun.jersey.api.client.WebResource.handle(WebResource.jav a:562)
    at com.sun.jersey.api.client.WebResource.post(WebResource.java: 219)
    at App.main(App.java:194)


    What do you think I am doing wrong?

    Ken
     
  2. I've tried to adding the price parameters in the body of the request as json e.g.
    postBody: {xBoundMax=0.01, area=0.0006, zBoundMin=0.01, volume=0.000001, yBoundMax=0.01, yBoundMin=0.01, zBoundMax=0.01, xBoundMin=0.01}


    but this only results in a 500 response from the server.

    Could someone please give me hint of where the parameters are suppose to be include in the post request?


    Ken
     
  3. For what it is worth I've experimented with adding the additional price quote parameters as form data and query parameters.
    I also added trace of the rest request and response. This approach at past oauth authorization, but fails because the server
    can not find the volume or area input. But it is clear from the trace that it is being past to the server.

    Here is the trace what the additional parameters are added as form data:
    1 * Client out-bound request
    1 > POST https://api.shapeways.com/price/v1
    1 > Content-Type: application/x-www-form-urlencoded
    xBoundMax=0.01&area=0.0006&zBoundMin=0.01&volume =0.000001&yBoundMax=0.01&yBoundMin=0.01&zBoundMa x=0.01&xBoundMin=0.01
    1 * Client in-bound response
    1 < 500
    1 < Expires: Mon, 26 Jul 1997 05:00:00 GMT
    1 < Set-Cookie: whid=6; path=/
    1 < Set-Cookie: __cfduid=db45a0da4d10dec658ae5ca4bd4cd6fae1408893234810; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.shapeways.com; HttpOnly
    1 < Connection: keep-alive
    1 < Server: cloudflare-nginx
    1 < X-Powered-By: PHP/5.3.10-1ubuntu3.9
    1 < Cache-Control: no-cache, must-revalidate
    1 < Status: 500 Internal Server Error
    1 < Vary: Accept-Encoding
    1 < Transfer-Encoding: chunked
    1 < Date: Sun, 24 Aug 2014 15:13:55 GMT
    1 < CF-RAY: 15f07f1d9fd0047f-FRA
    1 < Content-Type: application/json; charset=utf-8
    1 <
    {"result":"failure","reason":"Field <volume> is required, but missing.\nField <area> is required, but missing."}

    Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: POST https://api.shapeways.com/price/v1 returned a response status of 500 Internal Server Error

    I would really appreciate some input from the Shapeways technical staff or the rest of the development community on what I am doing wrong.

     

  4. Can't help you with Jersey. Took a quick look at the javadocs, but it was not obvious to me how to setup the parameters for a POST.

    Someone else was having problems POSTing with a Java implementation. That thread is here: https://www.shapeways.com/forum/index.php?t=msg&th=13569 &start=0&

    I have a set of Java wrappers that use GSON and Scribe. Not open sourced yet, but I would be happy to share if you think it might help.