Kategorie

Operations with customers

Operations with Customers - GET, INSERT, UPDATE, DELETE

How to get customer by email
GET /odata/customer('email')

Request Type: GET

Enter the request URL: http://StoreURL/odata/customer('email')

Auth type: Bearer Token - paste the token generated in the previous steps

Get customer by email

How to delete customer
DELETE /odata/customer('email')

Request Type: DELETE

Enter the request URL: http://StoreURL/odata/customer('email')

Auth type: Bearer Token - paste the token generated in the previous steps

Please note that in DELETE operations, you will get only "Status: 200 OK" information if the item was successfully deleted.

How to add new customer
POST /odata/customer

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. 

URGENT: You don't have to specify all fields. You can add only that fields, which are important for you. Below you will find a full request to add a customer. Edit fields which you want, the rest can be removed and they will get a default value. Please note that e-mail and customer role are required to create a fully working customer.

{
"Username": null,
"Email": "enter customer email",
"AdminComment": null,
"IsTaxExempt": True/False,
"FreeShipping": True/False,
"AffiliateId": null,
"VendorId": null,
"Active": True/False,
"Deleted": True/False,
"Gender": null,
"FirstName": "Enter first name",
"LastName": "Enter last name",
"DateOfBirth": null,
"Company": null,
"StreetAddress": null,
"StreetAddress2": null,
"ZipPostalCode": null,
"City": null,
"CountryId": null,
"StateProvinceId": null,
"Phone": null,
"Fax": null,
"VatNumber": null,
"VatNumberStatusId": null,
"Signature": null,
"CustomerRoles": [
"Customer role ID",
"Customer role ID",
"Customer role ID"
],
"Id": "leave it empty",
"Addresses": []
}

How to update customer
POST /odata/customer

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. 

URGENT: Unlike adding a new customer, if you want to update the customer, you must enter all fields that exist and enter the ID of customer which you want update. You can use JSON presented in the previous chapter.

 

How to update whole customer
PUT /odata/customer('email')

Request Type: PUT

Enter the request URL: http://StoreURL/odata/customer('email')

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. 

URGENT: It's the PUT request, so you have to provide all available fields, also with the "id" field. 

How to set password
POST /odata/customer('email')/SetPassword

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer('email')/SetPassword

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. 

{
"password":"Enter password"
}

How to add new address to customer
POST /odata/customer('email')/AddAddress

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer('email')/AddAddress

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. What's important, API validate fields like store, so if you have Country enabled, you need to enter CountryId. In the other case you will receive error. CountryId and StateProvinceId can be found in the database.

{
"FirstName": "Enter the name",
"LastName": "Enter the last name",
"Email": "Enter the email",
"Company": "Enter the company name",
"VatNumber": "Enter the Vat Number",
"CountryId": "",
"StateProvinceId": "",
"City": "Enter the city",
"Address1": "Enter the address",
"Address2": "Enter the second line of address",
"ZipPostalCode": "Enter the zip code",
"PhoneNumber": "Enter the phone number",
"FaxNumber": "Enter the fax number",
"Id": "leave it empty"
}

How to update customer address
POST /odata/customer('email')/UpdateAddress

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer('email')/UpdateAddress

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page. In the update method, you need to enter the ID in proper field. 

{
"FirstName": "Enter the name",
"LastName": "Enter the last name",
"Email": "Enter the email",
"Company": "Enter the company name",
"VatNumber": "Enter the Vat Number",
"CountryId": "",
"StateProvinceId": "",
"City": "Enter the city",
"Address1": "Enter the address",
"Address2": "Enter the second line of address",
"ZipPostalCode": "Enter the zip code",
"PhoneNumber": "Enter the phone number",
"FaxNumber": "Enter the fax number",
"Id": "Enter the address id"
}

How to delete customer address
POST /odata/customer('email')/DeleteAddress

Request Type: POST

Enter the request URL: http://StoreURL/odata/customer('email')/DeleteAddress

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page.

{
"addressId": "Enter the address id"
}

back to top