python-3.xamazon-web-servicesamazon-cloudsearch

403 during posting data to cloudsearch


The following is the code:

import requests
url = 'document_url/documents/batch'
payload = "[{...}, {....}]"
headers = {'Content-type': 'application/json'}
response = requests.post(url, headers=headers, data=payload)
print('response code:', response.status_code)
print('response body:', response.json())

The following yields:

response code: 403  
response body: {'message': 'Request forbidden by administrative rules', '__type': 'CloudSearchException'}

The security rules are also opened up to all.

What could be the issue?


Solution

  • As per the discussion forums: https://forums.aws.amazon.com/thread.jspa?threadID=148917

    The document url should be:

    document_url/2013-01-01/documents/batch

    response after posting to the above url:

    {
      "status": "success",
      "adds": 1,
      "deletes": 0
    }