Import data
POST /wp-json/tca/v1/datapoints
This method accepts raw datapoint data by passing date
and data
parameteres.
If any of the passed parameters is missing, no data is going to be imported and the resource returns a 400 error code. If import is successfull, the resource returns a 200 success code.
Request
Parameter | Type | Required | Format |
---|---|---|---|
date |
String | Yes | 2018-01 |
data |
String | Yes | JSON |
Example
curl -X POST \
http://app.tcaingauge.com/wp-json/tca/v1/datapoints \
-H 'Authorization: Bearer Q0dXT2xUaFhLVmlyS0RRa3JpZGVhanlscToxSlZoREIzT3FxR2V0TVJrZ0JtbDhsS1lOTng3cWcyTDZ1N1BHSnZzZTdabmhrQzJDcA==' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-F date=2018-07 \
-F 'data=[{
"datapoint_id": 500,
"value": 16.5666
}, {
"datapoint_id": 501,
"value": 12.1899234
}]'
Responses
403
{
"code": "api_access_failed",
"message": "Authentication failed. Please provide a valid API Key and Secret.",
"data": {
"status": 403
}
}
Returned if authentication failed. Please check if you have enabled API Access and your authentication token.
400
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): data",
"data": {
"status": 400,
"params": {
"data": "Please send data using a valid JSON format."
}
}
}
Returned if data sent in data
param is not a valid JSON or if JSON string does not contain any data.
400
{
"code": "rest_invalid_param",
"message": "Please provide a date in a valid format.",
"data": {
"status": 400
}
}
Returned if date
is not in valid format.
400
{
"code": "data_not_imported",
"message": "Data import has failed. Please check your data format, date and datapoint ids.",
"data": {
"status": 400
}
}
Returned if none of datapopint ids are valid or active.
200
{
"status": true,
"message": "Data has been sucessfully imported"
}
Returned if data import has been successfull.