# API call doesn't return text/csv format

**URL:** <https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721>\
**Category:** Graylog Central (peer support)\
**Created:** [March 23, 2018, 3:47pm UTC](https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721 "2018-03-23T15:47:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kstanki2](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@kstanki2](https://community.graylog.org/u/kstanki2)\
**Post date:** [March 23, 2018, 3:47pm UTC](https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721/1 "2018-03-23T15:47:36Z")

</div>

I just upgraded from graylog 2.3.1 to the latest version and my reporting got broke

Basically I have a powershell script that runs ‘invoke-webrequest’ on an API request URL, and the result is a .csv file that I then run some formatting on and turn into a report. After upgrading, the API call no longer responds with text/csv content but instead the application/json format.

I went back into the API browser on the web console, made sure the response content type was ‘text/csv’ and generated a new Request URL (it was identical to the one I had generated previously). In the web console the Response Body was in text/csv format as expected, but when I try it in my report it just returns the application/json format.

Do I need to add something to my Request URL now to make it return text/csv?

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [March 23, 2018, 4:09pm UTC](https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721/2 "2018-03-23T16:09:22Z")

</div>

You have to provide an “Accept” HTTP request header which tells the Graylog REST API what kind of media type you want as response.

> [@Graylog 2.3.1 - Export to CSV via API Call](https://community.graylog.org/t/graylog-2-3-1-export-to-csv-via-api-call/4102):
>
> Hi everyone, right now i’m trying to automate the export of a simple search query to csv via the Graylog API. When i’m executing the following API Call i get a valid response: curl -u \<USER\>:\<PW\> -H 'Accept: application/json' -X GET 'https://localhost:9000/api/search/universal/relative?query=%22session%20opened%20for%20user%20root%22&range=300&decorate=false&fields=timestamp%2Cmessage' ... ...total\_results":13,"from":"2018-02-08T15:20:35.009Z","to":"2018-02-08T15:25:35.009Z","decoration\_stats"…

> [@CSV export using API](https://community.graylog.org/t/csv-export-using-api/3113):
>
> Can a search result be output to csv via API. I see the option within the interface under “More Actions”. But not finding where I can do this under the api browser.

---

<div class="post-metadata">

**Author:** ![kstanki2](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@kstanki2](https://community.graylog.org/u/kstanki2)\
**Post date:** [March 23, 2018, 4:31pm UTC](https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721/3 "2018-03-23T16:31:51Z")

</div>

That was it! thanks for the quick response

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [April 6, 2018, 4:32pm UTC](https://community.graylog.org/t/api-call-doesnt-return-text-csv-format/4721/4 "2018-04-06T16:32:06Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
