# 406 error when making POST request in API?

**URL:** <https://discuss.rapid7.com/t/406-error-when-making-post-request-in-api/40593>\
**Category:** API\
**Created:** [August 2, 2024, 4:53pm UTC](https://discuss.rapid7.com/t/406-error-when-making-post-request-in-api/40593 "2024-08-02T16:53:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssradm](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@ssradm](https://discuss.rapid7.com/u/ssradm)\
**Post date:** [August 2, 2024, 4:53pm UTC](https://discuss.rapid7.com/t/406-error-when-making-post-request-in-api/40593/1 "2024-08-02T16:53:05Z")

</div>

So I’m trying to write a snippet of code that basically returns search results when prompted with a certain IP address, and I’m trying to do this using `/api/3/assets/search` endpoint. However, I keep on getting a 406 error which implies there something wrong with my “Accept” header. Which makes no sense because I’m using “_/_” as my Accept header which should in theory accept any content type. This is my full snippet of code I’m using

```auto
import requests
import json

base_url = "https://<instance>:3780"

cookies_file_path = "rapid_cookies.txt"

with open(cookies_file_path, 'r') as file:
    cookies = file.read().strip()

ip_address = '10.XX.X.X' #Sample IP address here

headers = {
    "Cookie": cookies,
    'Content-Type': 'application/json',
    'Accept': '*/*'  
}

# The search criteria
search_criteria = {
    "match": "all",
    "filters": [
        {
            "field": "ip-address",
            "operator": "is",
            "value": ip_address
        }
    ]
}

url = f"{base_url}/api/3/assets/search"

# Make the API request
response = requests.post(url, headers=headers, json=search_criteria)

```

If I were to print out the response.json, it’d say something pertaining to a 406 error. I tried testing it on Postman and I’m getting the same issue. If anyone can lend a helping hand, I’d appreciate it greatly.

---

<div class="post-metadata">

**Author:** ![alistair\_longley](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/a/47e85d/32.png) [@alistair\_longley](https://discuss.rapid7.com/u/alistair_longley)\
**Post date:** [October 8, 2024, 8:48am UTC](https://discuss.rapid7.com/t/406-error-when-making-post-request-in-api/40593/2 "2024-10-08T08:48:07Z")

</div>

Try deleting your “Cookie” header, and not sending nexposeCCSessionID at all. Only send the “Authorization: Basic …” header for authentication

> [@Exceptions via API - 406's](https://discuss.rapid7.com/t/exceptions-via-api-406s/6681/7):
>
> For anyone still experiencing this, the issue is that the request contains the “nexposeCCSessionID” cookie. When making an API call, the only authentication needed is the “Authorization” header, if at some point the IVM server returns that session ID cookie, then any requests you send with it will error with HTTP 406 “Not Acceptable”. Delete the nexposeCCSessionID cookie from your request to fix this. Or as the other commenters mention, completely reinstall/update whichever software you were u…
