Vote for a Project | Climes API
This endpoint is useful to send your order's climes to selected project. This can be integrated post Order being created successfully.
Request Parameters
Request Schema
Name | Description | Type | Optional |
---|---|---|---|
partner_order_id | This partner_order_id is the same which was used while creating an order. | string | required |
climes | This same number of climes sent while creating the order. | number | optional |
project_id | This is the project selected by your user to support their climes with. You can get project_id from Get Projects API | string | required |
Endpoint
/v3/integrations/vote/choose
Method
POST
Headers
{
'x-api-key' : 'API_KEY',
'Content-Type' : 'application/json'
}
Payload
{
"partner_order_id": "876287372837786837",
"project_id" : "farmers-for-forests"
}
Response Parameters
Status Code
200
Response Data
{
"message": "Your choice has been recorded successfully"
}
Sample Request
- cURL
- NodeJs
- Axios
- Python
- Php
curl --location --request POST 'BASE_URL/v3/integrations/vote/choose'
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"partner_order_id": "876287372837786837",
"project_id" : "farmers-for-forests"
}'
const fetch = require('node-fetch');
const baseURL = 'BASE_URL/v3/integrations/vote/choose';
const apiKey = 'API_KEY';
const data = {
"partner_order_id": "876287372837786837",
"project_id": "farmers-for-forests"
};
const headers = {
'x-api-key': apiKey,
'Content-Type': 'application/json'
};
fetch(baseURL, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
// Handle the response
console.log(data);
})
.catch(error => {
// Handle the error
console.error(error);
});
var axios = require('axios');
var data = {
"partner_order_id": "876287372837786837",
"project_id" : "farmers-for-forests"
};
var config = {
method: 'post',
url: 'BASE_URL/v3/integrations/vote/choose',
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "BASE_URL/v3/integrations/vote/choose"
payload = json.dumps({
"partner_order_id": "876287372837786837",
"project_id": "farmers-for-forests"
})
headers = {
'x-api-key': 'API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('BASE_URL/v3/integrations/vote/choose');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'x-api-key' => 'API_KEY',
'Content-Type' => 'application/json'
));
$request->setBody('{
"partner_order_id": "876287372837786837",
"project_id" : "farmers-for-forests"
}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Sample Response
Below are sample responses for the above sample request.
Responses
- Success - 200
- Failure - 400
{
"message": "Your choice has been recorded successfully"
}
{
"message": "Bad Request! Please send all the variables properly."
}