Trying to use curl to call api response.
The only documentation is this:
https://stage-sgf-partner-api.azurewebsites.net/api/swagger/ui#/Person/PartnerApi_Person_GetGolferInfoByGolfId
I have ClientId and Password to use for the server.
This is the error message from server.
"Failed to load API definition.
Errors
Fetch error
NetworkError when attempting to fetch resource. https://stage-sgf-partner-api.azurewebsites.net/api/swagger.json
Fetch error
Possible cross-origin (CORS) issue? The URL origin (https://stage-sgf-partner-api.azurewebsites.net) does not match the page (https://www.systemtest.the18club.se). Check the server returns the correct ‘Access-Control-Allow-*’ headers."
Any suggestions what can be wrong?
$username='xxxxx';
$password='xxxxx';
$URL='https://stage-sgf-partner-api.azurewebsites.net/api/swagger/ui#/Person/PartnerApi_Person_GetGolferInfoByGolfId=114973-122';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result=curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
curl_close ($ch);
2
Answers
The people that built the API tells me the credentials should be send in the body. But this code below response "invalid credentials"
What can be wrong?
URL is wrong, you copied documentation link instead the API link which is like this:
https://stage-sgf-partner-api.azurewebsites.net/api/v1/Persons/GetGolferInfoByGolfId?golfID=1