Skip to main content

I am trying to use Clari API, but I am getting errors from the client side.  

I have already generated a token. 

Can you please provide a short example of using the API? just a simple request.

Thanks,

Shahar.

Hi, @ShaharP. This’ll likely depend on which data warehouse/BI tool/analytics tool you are using. I would recommend opening a case with our support team with the specific error messages you’re experiencing to get some help!


I'm just looking for short code examples in any language (preferably Python). Due to the fact that I could not find any examples in the documentation or on the internet, I believe that other people will find it useful as well.  


Hi @ShaharP ,

 

Here is a simple Python code block, you will note that this includes all of the types to export and that the forecast ID is not set, as this will be unique to your environment, as will the be the API Key:

import requests

url = "https://api.clari.com/v4/export/forecast/<forecast_name>"

payload = "{\n \"timePeriod\": \"2020_Q3\",\n \"typesToExport\": :\n \"forecast\",\n \"quota\",\n \"forecast_updated\",\n \"adjustment\",\n \"crm_total\",\n \"crm_closed,\n ],\n \"currency\": \"USD\",\n \"schedule\": \"NONE\",\n \"includeHistorical\": false,\n \"exportFormat\": \"CSV\"\n}"
headers = {
'Content-Type': 'text/plain',
'apikey': '<api_key>'
}

exportresponse = requests.request("POST", url, headers=headers, data=payload)

print(exportresponse.text)

This code generates the request, you can pull a list of jobs running or completed with the following code block:

import requests

url = "https://api.clari.com/v4/export/jobs"

payload = {}
headers = {
'apikey': '<api_Key>'
}

jobresponse = requests.request("GET", url, headers=headers, data=payload)

print(jobresponse.text)

Finally, to pull the results for your export job, you can take the ID from the list, or from the ID returned by the initial code block:

import requests

url = "https://api.clari.com/v4/export/jobs/<job_id>/results"

payload = {}
headers = {
'apikey': '<api_key>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

Steve Overton - Sr Technical Support Engineer - Clari


Thanks Steven! It works!


Reply