Support Questions
Find answers, ask questions, and share your expertise

CURL + CLoudera API - CSV retreaving

New Contributor

Hello guys,

 

Not sure it's the write place to expose this, so please feel free to redirect me if it is the case.

I'm trying to retrieve some data (timeseries) through my terminal using Curl. It works well, but even if I specify the content that I want to have as CSV, the output is always in json. Here is the command I type:

 

curl -k -H "content-type:text/csv" -X GET -u "user:pwd"  -i https://host/api/v6/timeseries?query=SELECT+allocated_memory_mb&contentType=text%2Fcsv

 

I also tried:

 

curl -k --header "content-type:text%2Fcsv" -X GET -u "user:pwd"  -i https://host/api/v6/timeseries?query=SELECT+allocated_memory_mb

 

and other combinations but none seems to work as expected.

Could you please help?

 

Thanks,

 

Ayoub

2 REPLIES 2

Cloudera Employee

Hi Ayoub,

 

The URL should be enclosed by single quotes ('). You also don't need to specify the content-type twice.

 

Please try the following:

 

 curl -k -X GET -u 'user:pwd'  -i 'https://host/api/v6/timeseries?query=SELECT+allocated_memory_mb&contentType=text/csv'

 

Let me know if that worked for you.

 

Best regards,

 

Michael

 

New Contributor

Thanka alot &contentType=text/csv option worked!!

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.