I am trying to add a new Remote Site Setting via API. I am using core PHP. After I run the following code I am getting this error.
$response = [
0 => {
"errorCode": "NOT_FOUND"
"message": "The requested resource does not exist"
}
]
It seems I am using wrong end point. Can anyone guide me what are the end points for add new remote site?
OR
if I can't use rest api then what will be the soap envelope and soap end URL
Please Help.
Here is my code.
$url = $instance_url . '/services/data/v53.0/metadata/RemoteSiteSetting';
//RemoteProxy, RemoteSiteSetting
$data = [
'fullName' => 'My First Hook',
'isActive' => true,
'url' => 'http://www.myServerUrl.com',
'description' => 'Used for Apex callout to mapping web service for my server'
];
$result = $this->callAPI('POST', $url, $data, $access_token, ['accountId' => $accountId]);
public function callAPI($method = 'GET', $url = '', $data = [], $access_token = '', $extras = []) {
$header = [
'Authorization: Bearer ' . $access_token,
'X-PrettyPrint:1',
'Content-Type: application/json'
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
switch ($method) {
case "GET":
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
break;
case "POST":
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
break;
case "PUT":
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
break;
case "DELETE":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
break;
case "PATCH":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
break;
}
$response = curl_exec($curl);
$response_object = json_decode($response);
return $response_object;
}