The ‘code’ query parameter provided in the HTTP request did not match the expected value

Occasionally I have an issue when I call an azure function from a logic app. This is the error:

{
“statusCode”: 400,
“headers”: {
“Pragma”: “no-cache”,
“Cache-Control”: “no-cache”,
“Date”: “Thu, 24 Nov 2016 00:32:40 GMT”,
“Server”: “Microsoft-IIS/8.0”,
“X-AspNet-Version”: “4.0.30319”,
“X-Powered-By”: “ASP.NET”,
“Content-Length”: “103”,
“Content-Type”: “application/json; charset=utf-8”,
“Expires”: “-1”
},
“body”: {
“Message”: “The ‘code’ query parameter provided in the HTTP request did not match the expected value.”
}
}

When you browse the internet you will find this issue multiple times. In all posts, it’s mentioned that the function can successfully be tested via the Azure Portal. So, there’s no issue with the function code. If you open the logic app and look for the code query parameter when calling the function, you will not find that.

The next step is to go to the portal and find the function in the function container. On the main page where you find the function code, you will see a link “Get function URL”. If you click this link, you will for instance see the following Url:
https://ahak-functions-dev.azurewebsites.net/api/FilterTGDocument?code=jgIS6gEYzTuJZbbYHhPXNSk7Z8AS1R6uGvv5E97K4p9KwP/AnUuAhg==&clientId=default.

Here you see the code parameter and a parameter clientId equals default. ClientId default refers to the default function key. You can find this key on the Manage tab. Some posts indicate that you have to regenerate the default key or add a new function key. Both solutions didn’t work for me.

Finally I found a post that said I had to duplicate the function call in the Logic App. So, after FilterTGDocument I added a second call named FilterTGDocument2. After resubmitting the logic app I noticed I could successfully call both functions. Strange but true. Then I removed functional call FilterDocument2 again and it kept working. Strange indeed, but I wanted to share the results of my little investigation. The issue has been reported to Microsoft.

Leave a Reply

Your email address will not be published. Required fields are marked *