Adding images as posts in boxes and clients
Adding images as posts in OZmap is performed in two main steps:
Creating the post on the element (such as a Box or a Client).
Adding the image to the newly created post.
Below, we detail these steps with two practical examples of API calls in OZmap: one demonstrates how to perform this procedure for Boxes, and the other for Clients.
Example 1
Below is an example of how to create a post with an image in a Box in OZmap.
1. Create a Post in a Box
We will use the following Box data as an example:
{
...
"kind": "Box",
"project": "5d9f3ff9200141000647f814",
"name": "CTO - Example",
"pole": "5da61d8e493d9c000666541d",
"boxType": "589ddcf07dfe452f10d7c274",
"hierarchyLevel": 2,
"implanted": false,
"observation": "",
"history": [],
"createdAt": "2019-10-15T19:29:23.366Z",
"updatedAt": "2024-12-07T21:25:17.110Z",
"tags": [],
"id": "5da61e13493d9c0006665474",
"lng": -48.52691441774369,
"lat": -27.57763947862014
...
}
Using the Box ID (5da61e13493d9c0006665474
), we can create the "Example" post linked to this Box. Use the following API call:
curl --location 'http://example.ozmap.com.br:9090/api/v2/posts' \
--header 'Authorization: <API Key>' \
--form 'title="Example"' \
--form 'observation="Created as an example"' \
--form 'element.id="5da61e13493d9c0006665474"' \
--form 'element.kind="box"'
If the post is successfully created, the API will return the status 201 Created and the following response:
{
"element": {
"id": "6679af75a6f60e0014e5e5e5",
"kind": "box"
},
"owner": "64de32ae14ce55033e8b1f63",
"tags": [],
"title": "Example",
"observation": "Created as an example",
"files": [],
"creatorData": {
"id": "64de32ae14ce55033e8b1f63",
"name": "example",
"username": "example"
},
"_id": "67573d571cd4d097fa52d5fd",
"createdAt": "2024-12-09T18:56:23.189Z",
"updatedAt": "2024-12-09T18:56:23.189Z",
"__v": 0,
"id": "67573d571cd4d097fa52d5fd"
}
2. Add an Image to the Created Post
With the post created, identify the Post ID (67573d571cd4d097fa52d5fd
). Now, add an image to the post by specifying the element type (post
), the Post ID, and the image file path.
Use the following API call:
If the image is successfully added, the API will return the status 201 Created and the following response:
Example 2
Below is an example of creating a post with an image in a Client in OZmap.
1. Create a Post in a Client
We will use the following OZmap Property data as an example:
Using the Property ID (6400e9c18a21020d261e7df4
), we can create a post titled "Example" linked to this Client. Use the following API call:
If the post is successfully created, the API will return the status 201 Created and the following response:
2. Add an Image to the Created Post
With the post created, identify the Post ID (67573d571cd4d097fa52d5fd
). Add an image to the post by specifying the element type (post
), the Post ID, and the image file path.
Use the following API call:
If the image is successfully added, the API will return the status 201 Created and the following response: