function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
inbaljS2inbaljS2 

trying to send http request and getting 401 Response Message=Unauthorized error

Hi all,

I have created a listener page on force.com sites, in which I use the regular guest user permissions and not a customer portal user. 

 

The problem is that when ever the 3rd party company is trying to send httpRequest for me to that page they are keep getting as a response this error message:

"Error posting XML message. Response Code=401 Response Message=Unauthorized" 

 

I believe it is probably related to a permissions issue, I just don't really understand why. 

 

It's probably important to say that the page is a HTTPS page. 

 

Anyone have any idea on why this is happening? And how I can fix that?

 

Thank you,

Inbal

 

bob_buzzardbob_buzzard

I've found that if and unauthenticated user accesses the site and there are any problems with your pages/controllers that would lead to an error being displayed, you end up on an authorization required page.  It seems like the error pages are only available to authenticated users.

 

Try producing a very simple page and see if the 3rd party company can access that.

inbaljS2inbaljS2

Hi Bob,

thanks for replying.

 

I also saw that when there is an error they can't actually reach to the page - so I tried to check the page on my own by taking the XML string the 3rd party company sent me and added it to the URL.

 

I didn't got exceptions.

 

But anyway I will give it a try with a simple page as well.

Is it possible that the problem is being caused since I am trying to update a contact record after reading the XML sent?

Although it seems weird for me since the error message they get is "error sending XML", what do you think?

 

Thank you,

Inbal

bob_buzzardbob_buzzard

I guess from their perspective the error is with sending the XML - anything that you are doing server side is hidden from them.  

 

Most of the time my issues have been down to pages/classes not being available to the guest user.

Pradeep_NavatarPradeep_Navatar

Basically this error seems to be due to URL and associated parameters. Explore your code, I think you have set a wrong URL in setEndpoint method inside httpRequest class for the endpoint of the external server for this request. The problem with your url could be related with parameters.

 

Hope this helps.

inbaljS2inbaljS2

Hi ,

I wasn't the one sending the request.

I am getting the request from a 3rd party company.

Any suggestions for that?

Thanks

Inbal