Creating Resources¶
User can create a resource by sending a POST request (with JSON payload) to a defined endpoint. Following examples show required parameters and JSON bodies.
An example of creating a resource - a new user
is illustrated it the example below.
Create Customer¶
- POST /customer/¶
Create a customer. Note that customer’s location is required.
Sample request:
POST /customer/ HTTP/1.1 Host: api.fieldaware.net Authorization: Token d943a51d68c44ca38cab9abda20a4d18 Content-Type: application/json { "name": "BigData", "email": "bdata@mailinator.com", "phone": "003537876645", "website": "www.bdata.net", "discount": 8, "location": { "name": "Head", "streetName": "Guiness Avenue", "locality": "Dublin", "postcode": "Dublin8", "country": "Ireland" } }
- Request JSON Object:
name (string) – Name of the customer
email (string) – Customer’s email
phone (string) – Customer’s phone number
discount (number) – Discount rate
location (obj) – JSON object representing customer’s location (required)
Sample response:
HTTP/1.1 201 CREATED Content-Type: application/json Location: "https://api.fieldaware.net/customer/4d18011294364a85a1c5541b9b4a0eee" { "link": { "url": "https://api.fieldaware.net/customer/4d18011294364a85a1c5541b9b4a0eee", "rel": "detail" }, "location": { "link": { "url": "https://api.fieldaware.net/location/3b0fd4f427ac47bfa02c956a8f3179c9", "rel": "detail" }, "uuid": "4a1de64d6b184abfb5692d2443dfa4d2", }, "uuid": "3b0fd4f427ac47bfa02c956a8f3179c9", "email": "user10@glidebooks.com", "firstName": "Blaise", "lastName": "Champlin", "locale": "en_US", "phone": null, "platform": "ios", "role": "Admin", "timezone": "Europe/Dublin", "customFields": {}, }
- Status Codes:
201 Created – when the resource is created successfully
404 Not Found – when the resource can not be found
- Response JSON Object:
link (obj) – JSON object representing a link to the created item
uuid (string) – UUID reference number of the newly created customer
location (obj) – JSON objects representing customer’s location