WordPress Plugin with Postman

Using the WP plugin with Postman to create a guest and quote, user receives an error "not authorized to create guest".

  • Chris Hynes states, "Usually this 403 issue where they are passing valid creds and getting a WAF error page means they're not passing User-Agent in their code which is required. Postman passes it automatically."
  • Robin Michael suggests the following:

Would you please put in a cURL equivalent of your request/response?  Please anonymize the passsword+token (put ****) and make sure you are posting a User-Agent Postman automatically adds this to requests by default, which might be your issue.
 
From the Developer/API Settings page
 
Data Format 
Everything is JSON, and requires Content-Type: application/json and/or Accept: application/json headers. 

Use a user agent header to identify yourself on all calls. For example: User-Agent: My Acme App.
  • Robin Michael also suggests the following:

I was able to post your sample data, but looking at your code you are not setting the User-Agent correctly check my PHP example at the end and I use the same format as your other headers in the array but you are doing this
'User-Agent' => 'Staging App' which is not going to work
 

cURL

 
Request
 
POST https://api.ownerrez.com/v2/guests

curl --location 'https://api.ownerrez.com/v2/guests' \
--header 'Authorization: Basic <auth here>' \
--header 'Content-Type: application/json' \
--header 'User-Agent: HappyTimes' \
--data-raw '{
"email_addresses": [
{
"address": "test@test.com",
"is_default": true,
"type": "home"
}
],
"first_name": "new first first_name",
"last_name": "new last name",
"phones": [
{
"extension": "91",
"is_default": true,
"number": "123456789",
"type": "home"
}
]
}'

Response


"email_addresses": [ 

"address": "test@test.com", 
"id": 522277228, 
"is_default": true, 
"type": "home" 

], 
"first_name": "new first first_name", 
"id": 609582520, 
"last_name": "new last name", 
"phones": [ 

"id": 295365918, 
"is_default": true, 
"number": "123456789", 
"type": "home" 


}

 PHP equivalent from Postman 

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.ownerrez.com/v2/guests',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"email_addresses": [
{
"address": "test@tester.com",
"is_default": true,
"type": "home"
}
],
"first_name": "new first first_name",
"last_name": "new last name",
"phones": [
{
"extension": "91",
"is_default": true,
"number": "123456789",
"type": "home"
}
]
}',
CURLOPT_HTTPHEADER => array(
'User-Agent: HappyTimes',
'Authorization: Basic <auth here>',
'Content-Type: application/json'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;