Logic Apps: HTTP action block not sending "Content-Type" header

Ryan Matthes 16 Reputation points
2020-12-02T18:08:53.177+00:00

We have a REST integration running between Microsoft's Logic Apps service (on Azure) and our NetSuite tenant. Logic Apps can perform REST operations to e.g. GET data from external services, such as NetSuite. For NetSuite to respond to the GET request, it needs to know how we want its response returned -- as XML, as JSON, etc. So in the request, I add a "Content-Type" header with a value of "application/JSON". NetSuite can then interpret that and send its data back as JSON.

Unfortunately it doesn't look like Logic Apps is actually sending out the "Content-Type" header, so NetSuite doesn't know how to respond, and our integration fails. I know Logic Apps isn't sending this header because as a test I redirected the request to point to a second Logic App, which just returns any headers it receives. Sure enough, no "Content-Type" header is being returned by that second Logic App. As another test, if I hit the second Logic App with a request sent via Postman, one that I've verified contains a "Content-Type" header, then the second Logic App shows it received my "Content-Type" header. I can only conclude my first Logic App isn't sending out the header I need it to.

This is not documented behavior. In fact as documented, it should be working -- see "Omitted HTTP headers" here: https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

6 answers

Sort by: Most helpful
  1. jrobijn 16 Reputation points
    2021-01-14T09:24:36.397+00:00

    This is still an issue and needs to be fixed.

    I'm trying to query a 3rd party API that returns a 422 error if the application/json Content-Type header is not set and as of right now I'm simply unable to use Logic Apps to send recurring GET requests to this API.

    During a test run Logic Apps tells me that it actually did send the Content-Type header as input, but the 3rd party API returns an error. Meanwhile, if I do a simple curl (on my laptop) to the API endpoint with -H "Content-Type: application/json" the API returns a proper result.

    2 people found this answer helpful.

  2. Ryan Matthes 16 Reputation points
    2020-12-08T17:27:54+00:00

    Thank you for your help, Mayank.

    For POST request whatever Content-Type you are defined will be used.

    That's not what I'm seeing, unfortunately. I'm POSTing from one Logic App to another 'receiving' Logic App in this test. The request body is empty.

    Building:
    46289-building-http-request.png

    Executing:
    46268-http-request-sent.png

    Output:
    46269-http-request-output.png

    So no content-type is being sent on the request. The second 'receiving' Logic App shows no Content-Type in the headers it receives.
    46219-http-request-received-no-ct-header.png

    Compare that to this request sent to the same 'receiving' Logic App via Postman:
    46169-http-request-received-ct-header.png

    I can do another request with GETs if that would be helpful, just let me know.

    Again, thank you for your help!

    1 person found this answer helpful.

  3. MayankBargali-MSFT 70,936 Reputation points Moderator
    2020-12-08T11:48:33.317+00:00

    Hi @Ryan Matthes

    Can you please confirm if the HTTP request body JSON Schema doesn't have any value?
    As the default value will be {} which represents that the request will be application/JSON.

    I had some test with the logic app HTTP trigger for GET request and observed that when I have entered '{}' content in the request body of my HTTP trigger then I observed the same behaviour that you have mentioned. Removing this and testing with different content type I didn't observe any issue.

    For POST request whatever Content-Type you are defined will be used.

    Let me know if it helps and if you are still facing the issue.


  4. Johnathan Seal 1 Reputation point
    2020-12-10T21:42:08.53+00:00

    I am hoping the following code snip will help triage this issue:
    public async Task<TestRailTestCase> getTestCase(int testcasenumber)
    {
    string url = getTestrailTestCaseUrlSnip().Replace("|id|", testcasenumber.ToString());

            client.DefaultRequestHeaders.Accept.Clear();
    
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
            System.Text.ASCIIEncoding.ASCII.GetBytes(
               $"{getUserName()}:{getPassWord()}")));
    
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    
            MediaTypeWithQualityHeaderValue mediaType = new MediaTypeWithQualityHeaderValue("application/json");
    
            var res = await client.GetAsync(url);
    
            string content = await res.Content.ReadAsStringAsync();
    
            var testCase = JsonSerializer.Deserialize<TestRailTestCase>(content);
            return testCase;
        }
    

    gives:
    content "{\"error\":\"Content-Type header missing (use Content-Type: application\/json)\"}" string

    So, where do you set this?


  5. Tor Arne Gjelhus 1 Reputation point
    2021-01-25T20:03:24.463+00:00

    Hi

    If i read the bottom section here https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http#disable-location-header-check under known issues it seems to me that logic apps removed the content-type outbound without notification so what we see is as expected.
    I was facing the same issue as you was and i guess i will have to make an azure function for my scenario

    best regards
    Tor Arne Gjelhus

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.