With error.py
# Request with errors
# This is the same request as before, but the postal code is invalid (4 digits).
import base64
import pprint
from jsonrpclib import Server
server = Server("https://webservice.imxpostal.fr/smc/rpc/")
# Credentials to be given by IMX
USERNAME = "..." # given by IMX
PASSWORD = "..." # given by IMX
ACCOUNT = "..." # given by IMX
data = {
"account": ACCOUNT,
"reference": "your reference number 3",
"options": {
"service": "1",
"carrier": "gls",
"carrier_tracking_id": True,
"label": True,
},
"parcel_description": {
"weight": "2.4", # in kg
},
"addressee": {
"name": "Olivier Migeon",
"company": "IMX postal",
"address1": "110b avenue General Leclerc",
"postcode": "9350",
"town": "Pantin",
"country": "FR",
},
}
output = server.api.declare_parcel(username, password, data)
pprint.pprint(output)
# Response is as follow :
#
# {u'errors': [{u'code': u'INVALID',
# u'field': u'addressee.postcode',
# u'message': u'Valeur invalide',
# u'value': u'9350'}],
# u'infos': [],
# u'label_source': u'gls',
# u'success': False,
# u'warnings': []}