Articles in this section
Category / Section

Resolve the "Method not allowed" issue while performing Dynamic connection string through External API in JavaScript Embedding

Published:

When working with dynamic connection strings through an external API, you may encounter a “Method Not Allowed” error in JavaScript embedding. This issue often arises in the embedded dashboard, even though the external API returns a value while running the external API application.

image.png

image.png

Solution

The issue can be resolved by adding the HTTPHead attribute to the method. This attribute indicates that the method will respond to HTTP HEAD requests. The HTTP HEAD method requests the headers that are returned if the specified resource would be requested with an HTTP GET method. Such a request can be done before deciding to download a large resource to save bandwidth, for example.

Here is a sample code snippet that demonstrates how to add the HTTPHead attribute to the method:

[HttpHead, HttpGet]
[Route("api/get-connection-details")]
public ApiResponse GetConnectionString()
{
    try
    {
        var dataSourceName = HttpContext.Current.Request.Params["datasourcename"];
        .......
    }
    catch (Exception ex)
    {
        ..........
    }
}

image.png

In the above code, the [HttpHead, HttpGet] attributes are added before the GetConnectionString() method. This allows the method to respond to both HTTP HEAD and GET requests.

References

  1. How to perform dynamic connection string?
  2. Dynamic connection external API sample
  3. Dynamic connection string in JavaScript Embedding
  4. KB article for performing Dynamic connection string
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Soundarya Mani Meharan
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied