Reputation: 1677
I'm trying to get PayPal user basic personal data.
When I pass attributes, it gives me this error:
Invalid request parameter: Requested Attributes are incorrect
API Docs:
https://developer.paypal.com/docs/classic/api/permissions/GetBasicPersonalData_API_Operation/
My code:
function GetBasicPersonalData(){
$paypal_config = Config::get('paypal');
$requestEnvelope = new RequestEnvelope();
$requestEnvelope->errorLanguage = "en_US";
$request = new GetBasicPersonalDataRequest();
$request->requestEnvelope = $requestEnvelope;
$request->attributeList = array('http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last', 'http://axschema.org/contact/email');
$service = new PermissionsService($paypal_config);
$response = $service->GetBasicPersonalData($request);
return $response;
}
This is how request looks like:
PayPal\Types\Perm\GetBasicPersonalDataRequest Object
(
[requestEnvelope] => PayPal\Types\Common\RequestEnvelope Object
(
[detailLevel] =>
[errorLanguage] => en_US
)
[attributeList] => Array
(
[0] => http://axschema.org/namePerson/first
[1] => http://axschema.org/namePerson/last
[2] => http://axschema.org/contact/email
)
)
And response:
PayPal\Types\Perm\GetBasicPersonalDataResponse Object
(
[responseEnvelope] => PayPal\Types\Common\ResponseEnvelope Object
(
[timestamp] => 2015-05-26T17:27:05.060-07:00
[ack] => Failure
[correlationId] => 02023e9639483
[build] => 2210301
)
[response] => PayPal\Types\Perm\PersonalDataList Object
(
[personalData] =>
)
[error] => Array
(
[0] => PayPal\Types\Common\ErrorData Object
(
[errorId] => 580022
[domain] => PLATFORM
[subdomain] => Application
[severity] => Error
[category] => Application
[message] => Invalid request parameter: Requested Attributes are incorrect
[exceptionId] =>
[parameter] => Array
(
[0] => PayPal\Types\Common\ErrorParameter Object
(
[name] =>
[value] => PersonalAttributeList
)
)
)
)
)
I don't see my mistake here, some help?
Upvotes: 1
Views: 957
Reputation: 1
Here is how it works for me:
{
"requestEnvelope": {
"errorLanguage": "en_US"
},
"attributeList": {
"attribute": [
"http://axschema.org/contact/postalCode/home"
]
}
}
Upvotes: 0
Reputation:
Just create a new PersonalAttributeList object to hold the array attributes:
$personal_attribute = new PersonalAttributeList();
$personal_attribute->attribute = array('http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last', 'http://axschema.org/contact/email');
$request->attributeList = $persoanl_attribute;
Upvotes: 3