HTTP request method not allowed

Hello.

When attempting to perform any HTTP request method on some https url I’m getting some CloudFront errors which I’ve never encountered before. Below is an example of a response body.

What is needed to be done to overcome this?

Content-Type: text/html
Server: CloudFront
Via: 1.1 XXX.cloudfront.net (CloudFront)
X-Amz-Cf-Id: XXX...
X-Amz-Cf-Pop: XXX...
X-Cache: Error from cloudfront

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: XXX....
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

Hi @rdt.one

I believe this might be an issue related to your cloudfront configuration, rather than with k6 directly? From what I can read online based on the issue you report, you have k6 perform an HTTP request using a method that the cloudfront endpoint is not configured to accept?

It would be super helpful to post an anonymized example script illustrating your use case in k6. Would you be comfortable sharing that?

Let me know if that’s helpful :bowing_man:

Hi @oleiade.

Thanks for replying. Please find below the script.

import {JOIN_PRESENTATION} from "../util/endpoint.js";
import http from 'k6/http';

export let options = {
  stages: [
    { duration: '1s', target: 1 }
  ],
  thresholds: {
    http_req_duration: ['p(99)<1500'], // 99% of requests must complete below 1.5s
  },
};

export default function loadEvents() {

  let joinPresentationPayload = `...`;

  http.put(JOIN_PRESENTATION, joinPresentationPayload, {
    headers: {
      'content-type': 'application/json',
    },
  });

}

@oleiade this is solved now. I did mistakenly change the api host with the web url :upside_down_face:. Case closed.

1 Like

Glad that was somehow helpful, and you found a solution :+1: