Invalid Response Code (409) when "alertId" key is received in response body. 

<!-- Summary. -->

When the body of a valid response contains a Key of "alertId", like below:

{
    "Key1": "Value1",
    "Key2": "Value2",
    "alertId": "XX-6MH-QZ0-C8G-HC5-YYY"
}
The value of status_code throws 409 error.

response.status_code == 409

## Expected Result

response.status_code == 200

## Actual Result

response.status_code == 409

## Reproduction Steps

    try:
        response = requests.patch(
            "https://XXXXXX,
            headers=my_header,
            params=query,
            json={
                "Key": "Value"
            }
        )
 response.raise_for_status()

## System Information

AWS Lambda Python 3.9 runtime.

<!-- This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c). -->


This behavior you're seeing is not something we can control, Requests is only the messenger between your code and the server you're contacting. You'll have to read their documentation to see why you're receiving that status code.

Hi Seth,

Its an API that generate alert IDs when it receives requests. On postman,
we get the whole body with HTTP 200.
Even via Python 3.9 the "requests" library returns the correct data as long
as we do not use "response.raise_for_status()".

I noticed that if the response does not have the custom key of "alertId"
everything works well. In this case, even if the "alertId" is a custom
field in the body, "response.raise_for_status()" treats it as a HTTP
response code.

Regards,
Kuldeep Saxena


On Mon, 24 Jan 2022 at 13:34, Seth Michael Larson ***@***.***>
wrote:

> This behavior you're seeing is not something we can control, Requests is
> only the messenger between your code and AWS. You'll have to read their
> documentation to see why you're receiving that status code.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/psf/requests/issues/6047#issuecomment-1020107229>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AUUH5ZUQ43FQ6ZUIW7DXMXTUXVIPHANCNFSM5MVCYFVQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


Hi @PinchofLogic,

`raise_for_status()` is specifically for raising an exception on non-200 status codes. 409 is the service in question letting you know that there is some conflict with the resource. It may return relevant data in the response, but you'll need to check. If you don't want Requests to throw an exception for non-200 status codes, you'll want to remove that line from your code.

For more help with AWS products, I'd recommend reaching out to [AWS Support and Customer Service](https://aws.amazon.com/contact-us/). This isn't an issue with Requests and we won't be able to provide further help.