2017-12-06 6 views
0

Ich bin im Moment ratlos, ich versuche, die Option zum Senden eines Pakets an einen UPS Access Point hinzuzufügen, die Dokumentation sagt mir, dass ich eine Benachrichtigung hinzufügen muss Objekt für UAP (013) und für ADL (012)UPS ShipmentRequest API JSON Benachrichtigung an den Access Point senden

Wenn ich die Dokumentation der Benachrichtigungsobjekt gelesen wird maximal 3 mal erlaubt, in der Regel in xml würde es wie folgt aussehen:

<ShipmentServiceOptions> 
    <Notification> 
    <NotificationCode>012</NotificationCode> 
    some other values (here..) 
    </Notification> 
     <Notification> 
    <NotificationCode>013</NotificationCode> 
    some other values (here..) 
    </Notification> 
</ShipmentServiceOptions> 

Aber da ich bin Mit JSON erstelle ich ein Array von Objekten:

$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '012']; 
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '013']; 

, wenn ich diese komplette Array JSon dekodieren, wird es wie folgt aussehen:

{ 
"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" 
    } 
}] 

}

Dies ist eine gültige JSON-Objekt, aber aus irgendeinem Grund, den ich erhalte immer die Fehlermeldung:

ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.

Wenn ich die Array-Werte ausflippen ich den Fehler bekommen:

UAP shipper notification code (013) and notification data (email or phone number) is required for UPS Access Point Delivery.

Das sieht für mich so aus, als würde nur 1 Wert aus dem Array gelesen werden, und das Lesen der Dokumentation führt zu der Annahme, dass es mehrere Notification-Schlüssel erwartet, aber ich habe wirklich keine Ahnung, wie ich mehrere Notification-Schlüssel in json hinzufügen würde das JSON-Objekt .. Jede Hilfe sehr

bearbeiten

geschätzt werden würde, wenn ich das JSON-Objekt konvertieren wie folgt aussehen:

"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" 
       } 
      } 
     }], 

Es gibt mir die folgende Fehlermeldung:

ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.

Swapping um die Elemente ändern nicht die Fehler

Antwort

0

Ich wusste, dass es etwas einfacher wäre, wenn etwas mehr als eine Stunde dauert zu beheben, Sie wissen es einfach ist ;-)

ich die xml getauscht Dokumentation mit der Dokumentation Web-Service, in xml den Knoten, an dem die E-Mail-Benachrichtigung Daten hinzugefügt wird aufgerufen:

/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMailMessage/

in der JSON-Dokumentation, die gleichen Knoten, der die Mail-Daten halten genannt wird:

/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMail/

Für Vollständigkeit, ist dies der richtige json Teil für das Benachrichtigungsobjekt:

{ 
"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" 
    } 
}] 

}

Verwandte Themen