SOLVED

Re: Webhook to create a SF task failing

Go to solution
Shashank_Sharma
Level 2

Webhook to create a SF task failing

Hi,

I'm trying to setup a webhook to create task in SF. I'm getting the 401 error. Error Message - "HTTP Error 401: Unauthorized access to URL".

I'm using the same SF user that is setup in the main Marketo-SF sync. Not sure what am I doing wrong here. Has anyone faced the same challenge and how did you fix it?

Thanks,

Shashank Sharma

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Webhook to create a SF task failing

Then someone turned off the authentication requirement on the other endpoint. You should also look to see if there are any custom headers set up in the other webhook definition (Webhooks Actions >> Set Custom Header).

The HTTP 401 isn't being generated before Marketo makes the webhook call, it's the response to the webhook call.

I hope you aren't running a public endpoint that allows anyone to hit your Salesforce instance without auth.

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Webhook to create a SF task failing

Since you haven't provided your code (at least not that I can see in mobile view) it won't be possible to troubleshoot this.

Shashank_Sharma
Level 2

Re: Webhook to create a SF task failing

Hi Sanford,

Here's the error screen containing the payload and the error details. Any insights on how to fix this would be really helpful!

webhook error_9_20.PNG

Thanks,

Shashank Sharma

SanfordWhiteman
Level 10 - Community Moderator

Re: Webhook to create a SF task failing

Well, "Session expired" is pretty clear here: this is not a public endpoint, and Salesforce expects you to transport an authentication token.  Otherwise, anybody could add tasks to any record in your db (you could deliberately create such a public endpoint, but it's not going to exist out-of-the-box).

I get the feeling you haven't thought through the OAuth token process. This is the reason OAuth + REST endpoints don't typically work with direct webhook calls (they require an intermediate hop to manage tokens).

Shashank_Sharma
Level 2

Re: Webhook to create a SF task failing

Thanks for sharing the thoughts! Actually, I have another webhook for adding leads to SF campaign as a member, this works fine. Screenshot below:

webhook success_9_21.PNG

I'm using the same approach to setup the task webhook and getting the 401 error. Not sure what I need to do differently to fix this!

SanfordWhiteman
Level 10 - Community Moderator

Re: Webhook to create a SF task failing

Then someone turned off the authentication requirement on the other endpoint. You should also look to see if there are any custom headers set up in the other webhook definition (Webhooks Actions >> Set Custom Header).

The HTTP 401 isn't being generated before Marketo makes the webhook call, it's the response to the webhook call.

I hope you aren't running a public endpoint that allows anyone to hit your Salesforce instance without auth.

Shashank_Sharma
Level 2

Re: Webhook to create a SF task failing

Hi Sanford,

That  was it. The custom header was missing from my call. Thanks for pointing me into the right direction!

Thanks,

Shashank Sharma

SanfordWhiteman
Level 10 - Community Moderator

Re: Webhook to create a SF task failing

Great!