Error: Proxy request failed with code 400 message ...
# ask-stanley-ai
t
Error: Proxy request failed with code 400 message {"error":"Bad content type"}
c
AI generated answer (using internal Slack threads):
The error message "Proxy request failed with code 400 message {"error":"Bad content type"}" indicates that the content type of the request you are sending is not accepted by the server. In the first thread, the user was advised to use 'multipart/form-data' as the content type when sending a file. The user was also provided with a code snippet on how to declare the content type and format the file content. Here is the code snippet:
Copy code
javascript
var contentType = 'multipart/form-data;boundary=XXFeedBoundary';
var fileContent = file.load(fileId).getContents();
fileContent = '--XXFeedBoundary\\n\\n' + fileContent + '--XXFeedBoundary--';
In the second thread, the user was having a similar issue when trying to send a JSON object as the body of a request. The user was advised to stringify the body of the request and to add an "Accept" header for the response type expected from the server. Here is the corrected code snippet:
Copy code
javascript
var body = {
    "manufacturerCode": "3",
    "code": "D21025139",
    "variantPartNos": [
        "D21025139_19034_89",
        "D21025139_19035_89"
    ],
    "flag": "STATUS_READY"
};

var response = <http://https.post|https.post>({
    url: "<url>",
    body: JSON.stringify(body),
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Basic XXXXXXXXXXXXXXXXXXXXX",
        "Accept": "<expected response type>"
    }
});
In the third thread, a user asked about a truncated response with system messages. The user was asked if they had set the content type in the response, implying that not setting the content type could lead to such an issue. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816467345
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813903868
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811279297
Please provide your feedback on this answer.