Difference between revisions of "Update Customer Name"
From MyMobileWorkers API
(→Successful) |
(→JSON As Body) |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 3: | Line 3: | ||
The Update Customer Name API call allows an existing customer to be updated with a new name by giving the existing name of a customer, along with the new name. | The Update Customer Name API call allows an existing customer to be updated with a new name by giving the existing name of a customer, along with the new name. | ||
| + | A customer name can be updated via two different methods - either as multi-part form data with the 3 parameters, or as JSNO content on its own, with the API key supplied within the JSON. | ||
==== Multi Part Form Data ==== | ==== Multi Part Form Data ==== | ||
| Line 11: | Line 12: | ||
|- | |- | ||
! URL | ! URL | ||
| − | | colspan="2" | http://base_url/api_path/version/ | + | | colspan="2" | http://base_url/api_path/version/companies/company/customers/updatename |
|- | |- | ||
! Type | ! Type | ||
| Line 17: | Line 18: | ||
|- | |- | ||
! Params: | ! Params: | ||
| − | | | + | | key || required |
|- | |- | ||
! | ! | ||
| Line 29: | Line 30: | ||
| colspan="2" | JSON | | colspan="2" | JSON | ||
|} | |} | ||
| + | |||
| + | ==== JSON As Body ==== | ||
| + | {| border="1" class="wikitable" | ||
| + | ! Create Job - JSON | ||
| + | ! colspan="2" | | ||
| + | |- | ||
| + | ! URL | ||
| + | | colspan="2" | http://base_url/api_path/version/companies/company/customers/updatename | ||
| + | |- | ||
| + | ! Type | ||
| + | | colspan="2" |POST | ||
| + | |- | ||
| + | ! | ||
| + | | JSON <br /> {key, existing_customer_name, new_customer_name} ||| required | ||
| + | |- | ||
| + | ! Response | ||
| + | | colspan="2" | JSON | ||
| + | |} | ||
| + | |||
| + | == JSON Contents == | ||
| + | |||
| + | {| border="1" class="wikitable" | ||
| + | |+ The Update Customer Name JSON | ||
| + | ! colspan="3" | Standard Fields | ||
| + | |- | ||
| + | ! Field | ||
| + | ! Expected Data | ||
| + | ! Required | ||
| + | |- | ||
| + | ! key | ||
| + | | varchar(255) || ✓ | ||
| + | |- | ||
| + | ! existing_customer_name | ||
| + | | varchar(255) || ✓ | ||
| + | |- | ||
| + | ! new_customer_name | ||
| + | | varchar(255) || ✓ | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | == Example Input == | ||
| + | |||
| + | ==== JSON As Body ==== | ||
| + | |||
| + | <source lang="java"> | ||
| + | { | ||
| + | "key":"your_api_key", | ||
| + | "existing_customer_name":"oldName123", | ||
| + | "new_customer_name":"newName456" | ||
| + | } | ||
| + | </source> | ||
== Example Curl Request == | == Example Curl Request == | ||
| − | curl -F api_key=YOUR_KEY -F existing_name=CUSTOMER_EXISTING_NAME -F new_name=CUSTOMER_NEW_NAME http:// | + | ==== Multi Part Form Data ==== |
| + | |||
| + | curl -F api_key=YOUR_KEY -F existing_name=CUSTOMER_EXISTING_NAME -F new_name=CUSTOMER_NEW_NAME http://api.mymobileworkers.com:8080/api/1/companies/company/customers/updatename | ||
| + | |||
| + | ==== JSON As Body ==== | ||
| + | |||
| + | curl -X POST -H "Content-Type: application/json" -d '{"key":"YOUR_KEY", "existing_customer_name":"OLDNAME", "new_customer_name":"NEWNAME"}' http://api.mymobileworkers.com:8080/api/1/companies/company/customers/updatename | ||
== Responses == | == Responses == | ||
| Line 45: | Line 103: | ||
<source lang="java"> | <source lang="java"> | ||
| − | |||
{"error_code":"CUS002","error_message":"Customer cannot be found"} | {"error_code":"CUS002","error_message":"Customer cannot be found"} | ||
{"error_code":"CUS011","error_message":"Customer name not provided. Please specify customer name in the request."} | {"error_code":"CUS011","error_message":"Customer name not provided. Please specify customer name in the request."} | ||
{"result":"failed","existing_customer_name":"testName24","new_customer_name":"darrenTest24"} | {"result":"failed","existing_customer_name":"testName24","new_customer_name":"darrenTest24"} | ||
| − | |||
</source> | </source> | ||
Latest revision as of 12:48, 14 November 2016
Contents |
[edit] Summary
The Update Customer Name API call allows an existing customer to be updated with a new name by giving the existing name of a customer, along with the new name. A customer name can be updated via two different methods - either as multi-part form data with the 3 parameters, or as JSNO content on its own, with the API key supplied within the JSON.
[edit] Multi Part Form Data
| Update Customer Name | |||
|---|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/updatename | ||
| Type | POST | ||
| Params: | key | required | |
| existing_name | required | ||
| new_name | required | ||
| Response | JSON | ||
[edit] JSON As Body
| Create Job - JSON | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/updatename | |
| Type | POST | |
| JSON {key, existing_customer_name, new_customer_name} |
required | |
| Response | JSON | |
[edit] JSON Contents
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | varchar(255) | ✓ |
| existing_customer_name | varchar(255) | ✓ |
| new_customer_name | varchar(255) | ✓ |
[edit] Example Input
[edit] JSON As Body
{ "key":"your_api_key", "existing_customer_name":"oldName123", "new_customer_name":"newName456" }
[edit] Example Curl Request
[edit] Multi Part Form Data
curl -F api_key=YOUR_KEY -F existing_name=CUSTOMER_EXISTING_NAME -F new_name=CUSTOMER_NEW_NAME http://api.mymobileworkers.com:8080/api/1/companies/company/customers/updatename
[edit] JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{"key":"YOUR_KEY", "existing_customer_name":"OLDNAME", "new_customer_name":"NEWNAME"}' http://api.mymobileworkers.com:8080/api/1/companies/company/customers/updatename
[edit] Responses
[edit] Successful
{"result":"success","existing_customer_name":"testName24","new_customer_name":"darrenTest24"}
[edit] Unsuccessful
{"error_code":"CUS002","error_message":"Customer cannot be found"} {"error_code":"CUS011","error_message":"Customer name not provided. Please specify customer name in the request."} {"result":"failed","existing_customer_name":"testName24","new_customer_name":"darrenTest24"}