0

Using Visual Studio 2017, I created a Function App with a Generic WebHook:

public static class FunctionWebHook
    {
        [FunctionName("FunctionWebHook")]
        public static async Task<object> Run([HttpTrigger(WebHookType = "genericJson")]HttpRequestMessage request, TraceWriter log)
        {
            log.Info($"Webhook was triggered!");

            string jsonContent = await request.Content.ReadAsStringAsync();

            log.Info(jsonContent);

            return request.CreateResponse(HttpStatusCode.NoContent);
        }
    }

The code is little more than the default template. I deployed this to my Azure account and tried to invoke it. I used the 'Get function url' link on the portal to get the correct URL, this included both the code and clientId parameters. When I try to POST JSON to the function (with content type set to application/json) I receive a 400 Bad Request:

{"Message":"The 'code' query parameter provided in the HTTP request did not match the expected value."}

I've check the code parameter and it is correct. I've also re-created the Function App several times, however I continue to receive the error. When I invoke the function using the Portal's Run command it executes correctly.

Has anyone come across this issue before?

markpirvine
  • 1,485
  • 1
  • 23
  • 54
  • Possible duplicate of [Azure function gives "The 'code' query parameter provided in the HTTP request did not match the expected value."](https://stackoverflow.com/questions/41261343/azure-function-gives-the-code-query-parameter-provided-in-the-http-request-di) – Kannaiyan Sep 17 '17 at 18:21
  • https://github.com/Azure/functionschallenge/issues/21 -- Issue is discussed here to resolve it. – Kannaiyan Sep 17 '17 at 18:22

2 Answers2

1

So I use Restlet Client for any API work and it seems it has a strange issue. I copied the default (Host Key) from the Portal and pasted the URL into the Restlet Client and for some reason the last '==' of the code parameter is dropped. I tried the request using Postman and that request worked!

Thanks for all of the comments and the reply!

markpirvine
  • 1,485
  • 1
  • 23
  • 54
0

Which key did you choose to authenticate your request? There are 3 types of keys. Please choose the default(Function key) and use the generated URL and the key. I tested it on my side and the function key could pass the validation from server.

enter image description here

For more information of function key and host key, link below is for your reference.

Azure Function WebHook API Keys

Amor
  • 8,325
  • 2
  • 19
  • 21