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
Mark RootMark Root 

Bizarre Remote Site Endpoint Error

I'm trying to use JSON to update posts on a WordPress website but am getting the following error saying the URL is not a valid endpoint. The endpoint works, though, and so is there something else that needs to be done to allow this data transfer to go through?  If I remove the "boaterspoint" subdomain and point to the root, which has a different WordPress site associated with it, everything works fine.  Any ideas?

07:10:24.459 (459013285)|CALLOUT_REQUEST|[103]|System.HttpRequest[Endpoint=http://boaterspoint.teammarinedealer.com/wp-json.php/posts/, Method=POST]

07:10:24.461 (461177013)|EXCEPTION_THROWN|[103]|System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = http://boaterspoint.teammarinedealer.com/wp-json.php/posts/
Best Answer chosen by Mark Root
Mark RootMark Root
Turns out the solution to this problem had to do with .htaccess file.  If you're going to use a callout to push Saleforce records to WordPress, you need to have the following line in your .htaccess file:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

All Answers

Terence_ChiuTerence_Chiu
I assume you already check if you added the endpoint in the remote site setting as per the error ? If you go to Setup menu-Security Controls->Remote Site Settings is the url for that endpoint already added as an entry. Salesforce won't all callouts to external endpoints if it has not been added to the setting.

https://help.salesforce.com/apex/HTViewHelpDoc?id=configuring_remoteproxy.htm&language=en (https://help.salesforce.com/apex/HTViewHelpDoc?id=configuring_remoteproxy.htm&language=en)
Amit Chaudhary 8Amit Chaudhary 8
please Go to  Setup->Security->Remote site settings
Enter below endpoint

http://boaterspoint.teammarinedealer.com/wp-json.php/posts/

And try again. Please us know if this will help you

Thanks
Amit Chaudhary
Mark RootMark Root
Remote Site Settings doesn't allow anything after the domain name and so what's entered now is simply "http://boaterspoint.teammarinedealer.com".  Is it possible that this isn't working because the "boaterspoint" subdomain resolves to a folder on the server (~/public_html/boaterspoint)?  Everything works fine if I enter the root domain without the "boaterspoint".
Mark RootMark Root
This issue is not resolved yet.  The subdomain as well as the full URL with the "/wp-json.php/posts/" both work fine which is why this is so strange.  SF accepts "http://teammarinedealer.com" at runtime but not "http://boaterspoint.teammarinedealer.com".  Why?
Amit Chaudhary 8Amit Chaudhary 8
In the remote site setting we need to add only domain detail. No need to add full URL. As SFDC will accept only domail name only.

just add http://boaterspoint.teammarinedealer.com
 
Mark RootMark Root
Turns out the solution to this problem had to do with .htaccess file.  If you're going to use a callout to push Saleforce records to WordPress, you need to have the following line in your .htaccess file:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
This was selected as the best answer