Skip to main content

Create new operation

Creates a new scheduled operation with the specified values. The operation can be updated only if it's in scheduled state

 POST /api/1.0/operation
caution

parameters with * are mandatory

Body


* project: <Integer> The project id,
* name: <String> The new operation name,
* scheduledTime: <String date> The operation scheduled time date (YYY-MM-DD HH:mm:ss),
* route: <Integer> The route id,
drone: <Integer> The drone id,
batteries: <Array> Array of all the batteries (serial number) for this operation,
payload: <Float> Float value between 0 and 2 (kg),
pic: <Integer> User id for the piclot in command,
groundOperators: <Array> Array of user id representing the ground operators for the operation
comments: <String> Comments for the operation,


Response

Model: application/json


{
"status": <Sting> Message with the call status
"id": <Integer> the unique id of the new created operation
"warning": <Array> Array of messages with warnings on the operation creation
"error": <Array> Array of error messages (only if the creation failed, if the call works this key is not returned)
}

Example

const fetchData=async ()=>{
let j,response;
const serverResponse = await fetch(`https://cloud.rigi.tech/api/1.0/operation`, {
mode: "cors",
method: "POST",
referrer: "no-referrer",
headers: {"authorization": "Bearer " + token}
body: JSON.stringify({
"project":22,
"name":"test operation api",
"scheduledTime":"2022-07-19 11:00:06",
"route":14,
"batteries":["BAT-MT-01-00100", "BAT-MT-01-00104"],
"payload":"1",
"pic":34,
"groundOperators":[32,39]
}),
})
if(!serverResponse.ok){
try {
switch (serverResponse.status){
case 400:
j = await serverResponse.json();
break;
case 403:
response = { message: "Forbidden access to data" };
case 404:
response = { message: "Address not found" };
default:
j = await serverResponse.json()
}
} catch (e) {
response = { message: "Error fetching data" };
}
}else{
j = await serverResponse.json()
}

response = { data:j };
const {data, message} = response
if(message) console.debug(message)
if(data) console.debug(data)
}
fetchData()

Answer:

{
"status": "Operation created",
"id": 1042,
"warining":[
"There is no drone assigned. You will need to set it before the operation starts"
]
}