Get /models/v1 Returning 'invalid Auth/bad Request'

Discussion in 'Shapeways API' started by robs_mw, Feb 9, 2017.

  1. robs_mw
    robs_mw Well-Known Member
    Hi,

    I tried to run a script that I wrote long time ago, but now a call to GET /models/v1 is returning
    "Exception : Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)"

    To verify there's nothing wrong with oauth, I tested with a GET /models/{modelId}/v1 in the same class function, and that one works without a problem...
    Also I tried several of the stock PHP scripts that Shapeways provided, and they work with my consumer key and access token (but there's no sample provided calling GET /models/v1 !)

    Code snippet:

    I call:
    $oauth->fetch(API_URL_BASE."/models/v1", $page, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));

    where API_URL_BASE is defined outside the class ( define('API_URL_BASE',$api_url_base); and
    $api_url_base = "http://api.shapeways.com";)
    $page = 1

    this call:
    $oauth->fetch(API_URL_BASE ."/models/$modelId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
    works without a problem, where $modelld is set to one of my own models obviously

    Is it my script, or the API has a problem at Shapeway side?

    Best regards,
    Robert
     
  2. stonysmith
    stonysmith Well-Known Member Moderator
    Is it possible that the model you are retrieving has either been deleted or is part of a group of variants?
     
  3. robs_mw
    robs_mw Well-Known Member
    No, the GET /models/{modelId}/v1 call works fine
    The problem is with GET /models/v1 which supposed to give me a list of all my models
     
  4. robcapo
    robcapo Shapeways Employee Dev Team
    Hey Rob,

    Do you have any more information on the JSON response from the API endpoint? Did you recently enable variants for your models? I'm looking at our logs and I see a couple responses that say:

    {
    "result": "failure",
    "reason": "Model id XXXXXX uses variants and cannot be accessed from this endpoint"
    }
     
  5. robs_mw
    robs_mw Well-Known Member
    Hi Rob,

    You are rite, I managed to extract the json, and it gives the error that you mentioned.

    However, I have never ever (willingly) configured variants on any of my products (as far as I can recall).
    Only for this model, I had an issue that I suddenly / unintentionally had 2 products from the same model (not sure how).
    I would love to delete 1 product (which is not for sale, so can not have variants), but have no idea how to do that.
    And the other product of this model, doesn't have variants (see yourself: http://shpws.me/Mt2o)

    Do also note the other thread from Woody64, who identified the same problem (but apparently having variants in use)

    Q1: how to delete a product?
    Q2: how to check if I have variants in use somewhere easily? (and how to get rid of it?)
    Q3: why is Get /models/v1 failing on a model that doesn't seem to have variants?

    BR,
    Robert
     
  6. robcapo
    robcapo Shapeways Employee Dev Team
    Hey Robert,

    A1: https://www.shapeways.com/shop/inventory/ Lists out all of your products. There's an X next to each one that will allow you to delete them.
    A2: The easiest way to check if your product uses variants is on the product edit page. There's a section called "variants" that will display any variants being used.
    A3: You are correct, in this case, our error messaging just needs improvement. It looks like the reason this call is failing is actually because your model belongs to two products. If you delete one of those products, the call should work again.
     
  7. robs_mw
    robs_mw Well-Known Member
    Hi Rob,

    1. ah, I overlooked that! Just now I successfully removed the product
    2. with easy I meant NOT having to visit every single product page!...
    I hope your API fix can at least indicate if a model is used in a product variant
    3. indeed, after having removed that product, now everything is working fine again! (as I'm not using variants anywhere)

    Thanks,
    Robert
     
  8. robcapo
    robcapo Shapeways Employee Dev Team
    Hey Robert, thanks for the feedback!

    We're working on reducing the feature fragmentation between our API and shapeways.com. Ideally, variants wouldn't be causing these endpoints to fail at all! We'll be sure to let the community know when that happens :)
     
  9. imdaveho
    imdaveho Shapeways Employee Product Team
    @robs_mw using the /models endpoint will now return the models regardless if they are variant-ed; getting more info on the model (/models/{modelId} and /models/{modelId}/info) will not work since it impacts the data model related to the difference between models and products