How to get Countries
Why is this necessary?
You need a valid Country Id to be able to add a Shipping Address, Billing Address and a Payment Method to a basket
Getting into it
Get countries has no required parameters, but it has the following optional parameters:
- MaxItems
- NextPagingToken
If you are not sure what MaxItems
and NexPagingToken
are, take a look Here
The first thing you need to do is to attach your AccessToken to the request header See Quick Start if you are not sure how to do that.
Secondly you can add the maximum number of items wanted as query parameters like this:
api/v1/countries/5
this is not required and otherwise you will get all countries in your database
An example of how to get countries could be:
curl -D- -X POST https://umbracodemo1.ucommerce.net/api/v1/countries/5 \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \
If you get a successful response, you will get a list of countries returned to you.
Example:
{ "countries": [ { "cultureCode": "da-DK", "id": "1000c73d-3kod-df11-94f6-0003gg7btc8c", "name": "Denmark" }, { "cultureCode": "de-DE", "id": "2a45c12d-q8ur-kc20-24y6-1273kf7cbc8c", "name": "Germany" }, { "cultureCode": "en-GB", "id": "4833c73d-3c6d-pr11-94f6-5696fj7bcq9c", "name": "Great Britain" }, { "cultureCode": "nb-NO", "id": "9c30m03d-3o2d-rl71-9346-9203rt7bcc8c", "name": "Norway" }, { "cultureCode": "sv-SE", "id": "9b33c73d-3c6d-qk61-94f6-12097klbfe8c", "name": "Sweden" } ], "nextPagingToken": null }
Note: For an explanation of the Next Paging Token go to NextPagingToken.
Possible Errors that may occur:
Error | Description |
---|---|
Unauthorized (401) | The token expires |
Forbidden (403) | The token does not have access to this endpoint |
See Handling failures for more info.