Reputation: 501
I'm at a loss at the moment, I'm trying to add the option to send a package to a UPS Access Point, the documentation tells me I need to add a notification object for UAP (013) and for ADL (012)
When I read the documentation the notification object is allowed maximum 3 times, normally in xml it would look like:
<ShipmentServiceOptions>
<Notification>
<NotificationCode>012</NotificationCode>
some other values ( here..)
</Notification>
<Notification>
<NotificationCode>013</NotificationCode>
some other values ( here..)
</Notification>
</ShipmentServiceOptions>
But since I'm using JSON I create an array of objects:
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '012'];
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '013'];
when I json decode this complete array, it will look like:
{
"Notification": [{
"NotificationCode": "013",
"EmailMessage": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "[email protected]",
"FromName": "From Email"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}, {
"NotificationCode": "012",
"EmailMessage": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "From Email",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}]
}
This is a valid json object, but for some reason I keep getting the error:
ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.
When I flip the array values around I will get the error:
UAP shipper notification code (013) and notification data (email or phone number) is required for UPS Access Point Delivery.
This looks to me like only 1 value is being read from the array, and reading the documentation it leads me to believe it expects multiple Notification keys, but I really have no idea how I would add multiple Notification keys in json, which would invalidate the json object.. Any help would be greatly appreciated
Edit
when I convert the JSON object to look like this:
"ShipmentServiceOptions": [{
"Notification": {
"NotificationCode": "013",
"EmailMessage": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "fromemail",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}
}, {
"Notification": {
"NotificationCode": "012",
"EmailMessage": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "fromemail",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}
}],
It gives me the this error:
ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.
Swapping around the items doesn't change the error
Upvotes: 2
Views: 2672
Reputation: 501
I knew it would be something simple, if something takes more than an hour to fix, you know it's simple ;-)
I swapped the xml documentation with the web service documentation, in xml the node where the notification email data is added is called:
/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMailMessage/
In the JSON documentation that same node that holds the mail data is called:
/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMail/
For completeness, this is the correct json part for the notification object:
{
"Notification": [{
"NotificationCode": "013",
"EMail": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "fromemail",
"FromName": "fromemail"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}, {
"NotificationCode": "012",
"EMail": {
"EMailAddress": "[email protected]",
"UndeliverableEMailAddr": "[email protected]",
"FromEMailAddress ": "fromname",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}]
}
Upvotes: 4