Python Client Add_to_cart Response 200

Discussion in 'Shapeways API' started by xufeng0, Nov 4, 2016.

  1. xufeng0
    xufeng0 Member
    I am new to the shapeways api and I am wondering if I did anything wrong with the add_to_cart(self,params) function. When I try to put my model into the cart(after authorisation), I make a function call in
    response = client.add_to_cart(dict(modelId = mymodelId,materialId = mymaterialId))
    when I try to print the api response inside the __post(self,url,body=none,params=none) function in client class, the only thing I got is <Response [200]>
  2. stonysmith
    stonysmith Well-Known Member Moderator
    200 is usually "it worked"
  3. mkroeker
    mkroeker Well-Known Member
  4. xufeng0
    xufeng0 Member
    Thank you for your response smith. I took another look into what is wrong in the code and I find out that it is actually the response of add_to_cart function in the content field. The "content" field of the response of http post request is empty. A normal GET request will get a response like this:

    cookies: <RequestsCookieJar[<Cookie __cfduid=d593c78ef47f421dac3c8c4e96547f45a1478526637 for>, <Cookie whid=12 for>]>, _content:{"result":"success","modelId":"5221039","modelVersion":"0","title":"HBlogo","fileName":"HBlogo.stl","contentLength":1,"fileMd5Checksum":"c4ca4238a0b923820dcc509a6f75849b","fileData":"MQ==","nextActionSuggestions": some suggestions}, url:, status_code: 200, _content_consumed: True, encoding: utf-8, request: <PreparedRequest [GET]>, connection: <requests.adapters.HTTPAdapter object at 0x109c51310>, elapsed: 0:00:00.668650, raw: <requests.packages.urllib3.response.HTTPResponse object at 0x109d66210>, reason: OK, history: []

    And the POST request for add_to_cart will get a response like this:

    cookies: <RequestsCookieJar[<Cookie __cfduid=d72adcb1505edf4261dc4888a12a88c031478526693 for>, <Cookie whid=9 for>]>, _content: , headers: {'Content-Length': '0', 'Set-Cookie': '__cfduid=d72adcb1505edf4261dc4888a12a88c031478526693; expires=Tue, 07-Nov-17 13:51:33 GMT; path=/;; HttpOnly, whid=9; path=/', 'Accept-Ranges': 'none', 'Server': 'cloudflare-nginx', 'Connection': 'keep-alive', 'Date': 'Mon, 07 Nov 2016 13:51:33 GMT', 'CF-RAY': '2fe142bbd9d421fe-EWR', 'Content-Type': 'text/html; charset=UTF-8', 'Cf-Railgun': 'direct (waiting for pending WAN connection)'}, url:, status_code: 200, _content_consumed: True, encoding: UTF-8, request: <PreparedRequest [POST]>, connection: <requests.adapters.HTTPAdapter object at 0x1043d3f10>, elapsed: 0:00:00.290374, raw: <requests.packages.urllib3.response.HTTPResponse object at 0x1043da250>, reason: OK, history: []

    You can see that the content field is empty for some reason. Is it something wrong with my python application code or is it something wrong with the API?

    Thank you again for your response. And Sorry I did not make it clear the first time I made my post
  5. stonysmith
    stonysmith Well-Known Member Moderator
    That looks like a bug to me.. The response should contain these:

    result string A 'result' field stating 'success'
    nextActionSuggestions object Suggestions for next actions

    @imdaveho ... here's another one for your list <grin>