# Searching for messages using the REST API: json vs csv

**URL:** <https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434>\
**Category:** Graylog Central (peer support)\
**Tags:** curl\
**Created:** [November 7, 2022, 3:35am UTC](https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434 "2022-11-07T03:35:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jeremy](https://community.graylog.org/u/Jeremy)\
**Post date:** [November 7, 2022, 3:35am UTC](https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434/1 "2022-11-07T03:35:55Z")

</div>

Hi All,

I’m hoping you can help me. I’m trying to use the REST API to search for messages.

I have been able to successfully get results from the views/search/messages endpoint but the response is csv and seems to truncate long messages.

It seems like I should be able to use views/search/sync to perform the same search but I haven’t had any success.

Here’s how I’m getting the csv search results:

```auto
curl \
     -X POST "https://graylog/api/views/search/messages" \
     -u 'XXXXXX:XXXXXX' \
     -H 'X-Requested-By: clag' \
     -H 'Content-Type: application/json' \
     -H 'Accept: text/csv' \
     -d $'{
  "streams": ["601b4e875c22306d40d53109"], "query_string": { "type": "elasticsearch", "query_string": "LoggingInterceptor" }, "timerange": { "type": "relative", "range": 30000 } }'

```

This is my current attempt to use views/search/sync instead:

```auto
curl \
     -X POST "https://graylog/api/views/search/sync" \
     -u 'XXXXXX:XXXXXX' \
     -H 'X-Requested-By: clag' \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -d $'
{
  "queries":
  [
   {
    "id": "blah",
    "query":
    {
      "type": "elasticsearch",
      "query_string": "LoggingInterceptor"
    },
    "timerange": { "type": "relative", "range": 3600 }

   }
  ]
}

```

I don’t get any errors but I don’t get any results. It seems like I’m pretty close to an answer but I’m stumped at the moment.

Graylog version is 3.3

Thanks in advance,  
Jeremy

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [November 8, 2022, 3:00am UTC](https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434/2 "2022-11-08T03:00:38Z")

</div>

Hello @Jeremy && Welcome

Just touching base, I haven’t used 3.3 version in a couple years. I know there was some change in the API’s but I forgot. I’ll have to go through my notes & see what I can find, unless someone here jumps in.

Here is some old doc’s you can go through.

- [Graylog REST API — Graylog 3.3.8 documentation](https://archivedocs.graylog.org/en/3.3/pages/configuration/rest_api.html?highlight=api)

---

<div class="post-metadata">

**Author:** ![Jeremy](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jeremy](https://community.graylog.org/u/Jeremy)\
**Post date:** [November 9, 2022, 11:53pm UTC](https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434/3 "2022-11-09T23:53:42Z")

</div>

Thanks for the response. I will have some time next week to look at this again and I’ll get back to you one way or the other.

---

<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:** [November 23, 2022, 11:54pm UTC](https://community.graylog.org/t/searching-for-messages-using-the-rest-api-json-vs-csv/26434/4 "2022-11-23T23:54:21Z")

</div>

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