printdotio / printio-api

Issues + wiki for the api. See http://print.io/api
0 stars 0 forks source link

API request error #38

Closed pierre-dubuisson closed 9 years ago

pierre-dubuisson commented 9 years ago

I've encountered a problem with some test calls that I'm running on the API. This is with regards to the "shippingprices" method. Here is the error reference code which I've just got on my last attempt: 88735080-f5d4-4933-a8bb-5f55b6e001e7

micahasmith commented 9 years ago

Paste in your request json?

From here it looks like in your request you were not providing a value for Sku in one of your items.

pierre-dubuisson commented 9 years ago

{"ShipToPostalCode":"19146","ShipToCountry":"US","ShipToState":"PA","CurrencyCode":"USD","LanguageCode":"en","Items":{"SKU":"CanvsWrp-BlkWrp-10x10","Quantity":1}}

pierre-dubuisson commented 9 years ago

This is the URL which I'm using: https://staging.api.print.io/api/v/1/source/api/shippingprices?recipeId=d9a325f8-dcf6-4c8f-82c6-725bf1849265

micahasmith commented 9 years ago

I pasted your json in here https://staging-api.print.io/docs and got a response. Are you setting your Content-Type to application/json?

pierre-dubuisson commented 9 years ago

Yes good catch, it works now, thanks.

Couple of quick questions about the shipping options. I assume all orders to the US will have the standard shipping option, and that standard will always be the cheapest option? Also, when a shipping option has been selected, is it included in the details which are used to create the order via the "orders" API method?

micahasmith commented 9 years ago

Yeah. So for example, you got:

{
  "Result": [
    {
      "SKUs": [
        "CanvsWrp-BlkWrp-10x10"
      ],
      "ShipOptions": [
        {
          "CarrierName": "Standard",
          "MethodType": "Standard",
          "Name": "Standard",
          "Price": {
            "Price": 8.64,
            "CurrencyCode": "USD",
            "FormattedPrice": "$8.64",
            "CurrencyFormat": "${1}",
            "CurrencyDigits": 2
          },
          "Id": 1,
          "EstBusinessDaysTilDelivery": 12,
          "MethodId": 3
        },
        {
          "CarrierName": "Expedited",
          "MethodType": "Expedited",
          "Name": "Expedited",
          "Price": {
            "Price": 13.94,
            "CurrencyCode": "USD",
            "FormattedPrice": "$13.94",
            "CurrencyFormat": "${1}",
            "CurrencyDigits": 2
          },
          "Id": 2,
          "EstBusinessDaysTilDelivery": 4,
          "MethodId": 5
        },
        {
          "CarrierName": "Overnight",
          "MethodType": "Overnight",
          "Name": "Overnight",
          "Price": {
            "Price": 24.61,
            "CurrencyCode": "USD",
            "FormattedPrice": "$24.61",
            "CurrencyFormat": "${1}",
            "CurrencyDigits": 2
          },
          "Id": 3,
          "EstBusinessDaysTilDelivery": 2,
          "MethodId": 7
        }
      ]
    }
  ]
}

The standard option has an Id:1. In your /orders POST, you would set the item's ShipCarrierMethodId equal to 1 to indicate that was your selection.

Do NOT use the MethodId returned. That was bad naming on our part.

pierre-dubuisson commented 9 years ago

Does the standard option always have Id:1 ?

micahasmith commented 9 years ago

No.

However, IF you are interested in always selecting a standard option, in the /orders POST you can add "ShipType":"standard" instead of specifying "ShipCarrierMethodId": [Id] and that will always work.

pierre-dubuisson commented 9 years ago

Ok thanks.