Bad Request creating a webhook with C#

Hi!

I successfully implemented the authentication using ASP.NET Core, and basic access to the API. Now, wenn requesting (creating) POSTing to /hooks with the same header (including token), and the body containing eventKey and hookUrl, I get a BadRequest without further infos.

Can someone provide an example or give me a hint, how to get more info for debugging?

Best regards,
Stefan

@Stefan_Riedmann What does your outgoing request look like? URL, headers, body, etc. (Be sure to leave out any private details.)

Hi! I broke my problem down to one single test and created a gist. @mike.christianson

@Stefan_Riedmann I’ll have a look at your code.

In the meantime, do you have a capture of your request to the Infusionsoft server and its response? It would really help!

Here’s an example of what I mean.

My request:

POST /crm/rest/v1/hooks HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Authorization: Basic …
Connection: keep-alive
Content-Type: application/json
Host: api.infusionsoft.com:443

{
    "eventKey": "contact.edit",
    "hookUrl": "https://mikec.example.com/hook/callback"
}

Response from server:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Content-Type: application/json;charset=UTF-8
Date: Tue, 03 Oct 2017 20:30:54 GMT
Expires: Tue, 03 Oct 2017 20:30:54 GMT

{
    "eventKey": "contact.edit",
    "hookUrl": "https://mikec.example.com/hook/callback",
    "key": "37",
    "status": "Unverified"
}

Out of time for today. I’ll do this first thing tomorrow

@mike.christianson Never mind, while capturing the web traffic with Fiddler, I saw detailed errors which lead me to the reason. The contenttype/accept configuration didn’t fit. Unfortunately, .NET doesn’t include all information to the exceptions.
Thanks anyway for your help! I’ll probably come back soon with more problems :wink:

2 Likes