Ergebnis 1 bis 8 von 8

Thema: Problem to upload image with North-america API

  1. #1
    Spreadster
    Registriert seit
    25.10.2015
    Beiträge
    8

    Ausrufezeichen Problem to upload image with North-america API

    Hello,

    I'm having some problems creating new design with the North-america API platform, it used to work but not anymore (not since your last update I think).
    I am also using the European platform and it is working fine there.

    I'm creating the design in the NA API platform with this URL (#id is my account number)
    http://api.spreadshirt.com/api/v1/users/#id/designs

    Then I'm trying to upload an image with this URL (#designid is the design id):
    http://image.spreadshirt.net/image-s...png&method=PUT

    It gives me a 404 error and I don't know why (it's like the design id is not found, but the previous design creation was ok). I looked into the API docs but found nothing. I'm using the same method to upload to the EU platform with some other urls to create the design but the same url to upload the image, and it's working fine.
    The URL for uploading an image recently changed, it used to be the same for EU and NA platform, so I changed both but I don't know if it's correct.

    Can we use "http://image.spreadshirt.net/" to upload image to the North-America API platform?
    Is it something else? Please help.

    Thanks

    Geändert von komrod (13.09.2017 um 10:06 Uhr)

  2. #2
    Spreadshirt Team
    Elite Spreadster
    Avatar von Liza
    Registriert seit
    09.11.2012
    Beiträge
    287

    Standard

    Hi komrod,
    I've forwarded the problem and will let you know as soon as I get a response.


  3. #3
    Grand Spreader Elite Spreadster Avatar von lovetee
    Registriert seit
    10.03.2012
    Beiträge
    1.209

    Standard

    After creating Design on api.spreadshirt.com you should also receive the image URL to post your image data to.


  4. #4
    Grand Spreader Elite Spreadster Avatar von lovetee
    Registriert seit
    10.03.2012
    Beiträge
    1.209

    Standard

    Please see here for working samples: https://forum.spreadshirt.net/thread...PI-are-failing (the pastebin links of the lastest posts)

    Geändert von lovetee (13.09.2017 um 14:09 Uhr)

  5. #5
    Spreadster
    Registriert seit
    25.10.2015
    Beiträge
    8

    Standard

    Well, I understand why I had a 404 error, I should not have changed the URL. I'm using the received URL from the design creation and now I have a 403 error, like I don't have the right authorization.

    I don't know why it would authorized me to create a design and then make a 403 error on the image upload.
    I'm using the same method as the design creation but with the new URL and method, so it should work. And still, it used to work 2 or 3 months ago, before the API was updated.

    The first request is authorized and working, it creates the design.
    The second request doesn't work, like if the authorization was missing something. Of course I used the private key to crypt the "sig", as explained in the Pastebin and the docs.

    The authorization seems to be blocking everything.


    First request: design creation

    url: 'http://api.spreadshirt.com/api/v1/users/1226008/designs',
    method: 'POST',
    headers: { Authorization: 'SprdAuth apiKey="my api public key", data="http://api.spreadshirt.com/api/v1/users/#userid/designs POST 1505328896198", sig="9dff3c6603957b6a354c8df7fda9cdba7ef94f35", sessionId="45eb21b7-15f9-4bc3-8cbd-0fdf55a0ef05"' },

    I receive a success and the following resources :
    <resource xlink:href="http://image.spreadshirtmedia.com/image-server/v1/designs/1012554265" mediaType="png" type="preview"/>
    <resource xlink:href="http://image.spreadshirtmedia.com/image-server/v1/designs/1012554265" mediaType="png" type="montage"/>


    Second request: upload the image

    url: 'http://image.spreadshirtmedia.com/image-server/v1/designs/1012554265?mediaType=png&method=PUT',
    method: 'PUT',
    headers: { Content-type: 'image/png',
    Authorization: 'SprdAuth apiKey="my api public key", data="http://image.spreadshirtmedia.com/image-server/v1/designs/1012554265?mediaType=png&method=PUT PUT 1505328897471", sig="3cbfccc0da9f8b4915fb1cc4941f6e9520018f33", sessionId="45eb21b7-15f9-4bc3-8cbd-0fdf55a0ef05"' },

    body: <Buffer 89 50 4e 47 0d 0a 1a ... the image >


    Result :
    Status code: 403

    <HTML><HEAD>
    <TITLE>Access Denied</TITLE>
    </HEAD><BODY>
    <H1>Access Denied</H1>

    You don't have permission to access "http&#58;&#47;&#47;image&#46;spreadshirtmedia&#46 ;com&#47;image&#45;server&#47;v1&#47;designs&#47
    ;1012554265&#63;" on this server.<P>
    Reference &#35;18&#46;8202655f&#46;1505328897&#46;1c2cd89 b
    </BODY>
    </HTML>


    Everything seems to be right in the header.
    If my authorization method was wrong, it would not work for the first request.
    I tried also a multipart form data with the same result.


    Any idea?


  6. #6
    Grand Spreader Elite Spreadster Avatar von lovetee
    Registriert seit
    10.03.2012
    Beiträge
    1.209

    Standard

    The pastebin has it all - please review your code and compare.

    #userid is just a placeholder right?
    You don't need mediatype und your URL.

    Without having a look at the whole code, I can't help you any further.


  7. #7
    Spreadster
    Registriert seit
    25.10.2015
    Beiträge
    8

    Standard

    I figured it out. My authorization was ok.
    The error was because I didn't pass an user-agent in the header. That's strange because the image upload on the EU platform works fine without user-agent. So I guess the user-agent was turned mandatory for North-america platform.

    Thank you.


  8. #8
    Grand Spreader Elite Spreadster Avatar von lovetee
    Registriert seit
    10.03.2012
    Beiträge
    1.209

    Standard

    Zitat Zitat von komrod Beitrag anzeigen
    I figured it out. My authorization was ok.
    The error was because I didn't pass an user-agent in the header. That's strange because the image upload on the EU platform works fine without user-agent. So I guess the user-agent was turned mandatory for North-america platform.

    Thank you.
    for eu, be sure to put it there too

    ----------------------------------------------------------------------
    NEU! Productor v2.2.5 - Lade deine Designs hoch, erstelle in sekundenschnelle hunderte neuer Produkte, übersetze sie automatisiert und füge sie dem Marktplatz hinzu! Sieh selbst was der Vorgänger bereits konnte: https://youtu.be/9VD40vyTT_k.
    Teste es doch mit unserem Testaccount!
    ----------------------------------------------------------------------

    Freies Wordpress Plugin mit Spreadshirts API: https://wordpress.org/plugins/wp-spreadplugin/ / Hilfe: http://forum.spreadshirt.net/threads...rdpress-plugin

    Wordpress Webseiten Templates: http://themeforest.net/category/wordpress?ref=thimo

Stichworte

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein