Skip to content

Instantly share code, notes, and snippets.

@ScottNeaves
Created May 3, 2016 21:18
Show Gist options
  • Save ScottNeaves/a6595cb0bcc70611d46f8add4ac57029 to your computer and use it in GitHub Desktop.
Save ScottNeaves/a6595cb0bcc70611d46f8add4ac57029 to your computer and use it in GitHub Desktop.
Intermittent 400 errors on rate and label requests
#!/bin/bash
rand_ints=($RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM, $RANDOM)
#Get Rate
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[0]}" --header "Accept: application/json" --data '{"parcel": {"dimension": {"height": 7, "width": 3, "unitOfMeasurement": "IN", "length": 8}, "weight": {"unitOfMeasurement": "OZ", "weight": 14.0}}, "fromAddress": {"cityTown": "San Jose", "countryCode": "US", "stateProvince": "CA", "name": "Best Western", "postalCode": "95110", "addressLines": ["345 Park Avenue"]}, "rates": [{"inductionPostalCode": "95110", "carrier": "USPS", "specialServices": [{"specialServiceId": "DelCon"}], "parcelType": "PKG", "serviceId": "PM"}], "toAddress": {"cityTown": "Cupertino", "countryCode": "US", "stateProvince": "CA", "name": "Apple", "postalCode": "95014", "addressLines": ["1 Infinite Loop"]}}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/rates'
#Register Merchant
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[1]}" --header "Accept: application/json" --data '{"devUserName": "[email protected]", "shipperRegistration": {"phoneNumber": "5122901212", "address": {"city": "San Jose", "addressLine1": "345 Park Avenue", "state": "CA", "isoCountryCode": "US", "postalCode": "95110"}, "companyName": "Company Name", "fullName": "Customer Name", "emailAddress": "ordoro-pitney-'$RANDOM'@mailinator.com"}, "devPassword": "Vulcan1234"}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/developers/38196030/merchants/registration'
#Get Regular Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[2]}" --header "Accept: application/json" --data '{"parcel": {"weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}, "dimension": {"width": 3, "length": 8, "height": 7, "unitOfMeasurement": "IN"}}, "toAddress": {"company": null, "phone": "5122901212", "name": "Apple", "addressLines": ["1 Infinite Loop"], "cityTown": "Cupertino", "email": "[email protected]", "countryCode": "US", "residential": true, "postalCode": "95014"}, "rates": [{"serviceId": "PM", "parcelType": "PKG", "carrier": "USPS", "inductionPostalCode": "95110", "specialServices": [{"specialServiceId": "DelCon"}]}], "fromAddress": {"company": null, "phone": "5122901212", "name": "Adobe", "addressLines": ["345 Park Avenue"], "cityTown": "San Jose", "email": "[email protected]", "countryCode": "US", "stateProvince": "CA", "residential": true, "postalCode": "95110"}, "documents": [{"contentType": "URL", "fileFormat": "PDF", "type": "SHIPPING_LABEL", "size": "DOC_4X6", "printDialogOption": "EMBED_PRINT_DIALOG"}], "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
#Get International Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[3]}" --header "Accept: application/json" --data '{"documents": [{"contentType": "URL", "size": "DOC_8X11", "type": "SHIPPING_LABEL", "fileFormat": "PDF", "printDialogOption": "EMBED_PRINT_DIALOG"}], "parcel": {"dimension": {"length": 8, "width": 3, "height": 7, "unitOfMeasurement": "IN"}, "weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}}, "toAddress": {"company": null, "countryCode": "GB", "residential": true, "email": "[email protected]", "phone": "5122901212", "name": "Houses of Parliament", "addressLines": ["Parliament Square"], "postalCode": "0PW", "cityTown": "London"}, "fromAddress": {"company": null, "countryCode": "US", "residential": true, "postalCode": "95110", "email": "[email protected]", "phone": "5122901212", "name": "FirstName LastName", "addressLines": ["345 Park Avenue"], "stateProvince": "CA", "cityTown": "San Jose"}, "rates": [{"specialServices": [], "carrier": "USPS", "inductionPostalCode": "95110", "parcelType": "PKG", "serviceId": "PMI"}], "customs": {"customsInfo": {"reasonForExport": "DOCUMENTS", "currencyCode": "USD", "invoiceNumber": "1234567890"}, "customsItems": [{"quantity": 1, "unitPrice": 10.0, "unitWeight": {"weight": 3.0, "unitOfMeasurement": "OZ"}, "originCountryCode": "US", "description": "a banana"}]}, "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
#Get Rate
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[4]}" --header "Accept: application/json" --data '{"parcel": {"dimension": {"height": 7, "width": 3, "unitOfMeasurement": "IN", "length": 8}, "weight": {"unitOfMeasurement": "OZ", "weight": 14.0}}, "fromAddress": {"cityTown": "San Jose", "countryCode": "US", "stateProvince": "CA", "name": "Best Western", "postalCode": "95110", "addressLines": ["345 Park Avenue"]}, "rates": [{"inductionPostalCode": "95110", "carrier": "USPS", "specialServices": [{"specialServiceId": "DelCon"}], "parcelType": "PKG", "serviceId": "PM"}], "toAddress": {"cityTown": "Cupertino", "countryCode": "US", "stateProvince": "CA", "name": "Apple", "postalCode": "95014", "addressLines": ["1 Infinite Loop"]}}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/rates'
#Register Merchant
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[5]}" --header "Accept: application/json" --data '{"devUserName": "[email protected]", "shipperRegistration": {"phoneNumber": "5122901212", "address": {"city": "San Jose", "addressLine1": "345 Park Avenue", "state": "CA", "isoCountryCode": "US", "postalCode": "95110"}, "companyName": "Company Name", "fullName": "Customer Name", "emailAddress": "ordoro-pitney-'$RANDOM'@mailinator.com"}, "devPassword": "Vulcan1234"}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/developers/38196030/merchants/registration'
#Get Regular Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[6]}" --header "Accept: application/json" --data '{"parcel": {"weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}, "dimension": {"width": 3, "length": 8, "height": 7, "unitOfMeasurement": "IN"}}, "toAddress": {"company": null, "phone": "5122901212", "name": "Apple", "addressLines": ["1 Infinite Loop"], "cityTown": "Cupertino", "email": "[email protected]", "countryCode": "US", "residential": true, "postalCode": "95014"}, "rates": [{"serviceId": "PM", "parcelType": "PKG", "carrier": "USPS", "inductionPostalCode": "95110", "specialServices": [{"specialServiceId": "DelCon"}]}], "fromAddress": {"company": null, "phone": "5122901212", "name": "Adobe", "addressLines": ["345 Park Avenue"], "cityTown": "San Jose", "email": "[email protected]", "countryCode": "US", "stateProvince": "CA", "residential": true, "postalCode": "95110"}, "documents": [{"contentType": "URL", "fileFormat": "PDF", "type": "SHIPPING_LABEL", "size": "DOC_4X6", "printDialogOption": "EMBED_PRINT_DIALOG"}], "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
#Get International Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[7]}" --header "Accept: application/json" --data '{"documents": [{"contentType": "URL", "size": "DOC_8X11", "type": "SHIPPING_LABEL", "fileFormat": "PDF", "printDialogOption": "EMBED_PRINT_DIALOG"}], "parcel": {"dimension": {"length": 8, "width": 3, "height": 7, "unitOfMeasurement": "IN"}, "weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}}, "toAddress": {"company": null, "countryCode": "GB", "residential": true, "email": "[email protected]", "phone": "5122901212", "name": "Houses of Parliament", "addressLines": ["Parliament Square"], "postalCode": "0PW", "cityTown": "London"}, "fromAddress": {"company": null, "countryCode": "US", "residential": true, "postalCode": "95110", "email": "[email protected]", "phone": "5122901212", "name": "FirstName LastName", "addressLines": ["345 Park Avenue"], "stateProvince": "CA", "cityTown": "San Jose"}, "rates": [{"specialServices": [], "carrier": "USPS", "inductionPostalCode": "95110", "parcelType": "PKG", "serviceId": "PMI"}], "customs": {"customsInfo": {"reasonForExport": "DOCUMENTS", "currencyCode": "USD", "invoiceNumber": "1234567890"}, "customsItems": [{"quantity": 1, "unitPrice": 10.0, "unitWeight": {"weight": 3.0, "unitOfMeasurement": "OZ"}, "originCountryCode": "US", "description": "a banana"}]}, "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
#Get Rate
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[8]}" --header "Accept: application/json" --data '{"parcel": {"dimension": {"height": 7, "width": 3, "unitOfMeasurement": "IN", "length": 8}, "weight": {"unitOfMeasurement": "OZ", "weight": 14.0}}, "fromAddress": {"cityTown": "San Jose", "countryCode": "US", "stateProvince": "CA", "name": "Best Western", "postalCode": "95110", "addressLines": ["345 Park Avenue"]}, "rates": [{"inductionPostalCode": "95110", "carrier": "USPS", "specialServices": [{"specialServiceId": "DelCon"}], "parcelType": "PKG", "serviceId": "PM"}], "toAddress": {"cityTown": "Cupertino", "countryCode": "US", "stateProvince": "CA", "name": "Apple", "postalCode": "95014", "addressLines": ["1 Infinite Loop"]}}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/rates'
#Register Merchant
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[9]}" --header "Accept: application/json" --data '{"devUserName": "[email protected]", "shipperRegistration": {"phoneNumber": "5122901212", "address": {"city": "San Jose", "addressLine1": "345 Park Avenue", "state": "CA", "isoCountryCode": "US", "postalCode": "95110"}, "companyName": "Company Name", "fullName": "Customer Name", "emailAddress": "ordoro-pitney-'$RANDOM'@mailinator.com"}, "devPassword": "Vulcan1234"}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/developers/38196030/merchants/registration'
#Get Regular Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[10]}" --header "Accept: application/json" --data '{"parcel": {"weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}, "dimension": {"width": 3, "length": 8, "height": 7, "unitOfMeasurement": "IN"}}, "toAddress": {"company": null, "phone": "5122901212", "name": "Apple", "addressLines": ["1 Infinite Loop"], "cityTown": "Cupertino", "email": "[email protected]", "countryCode": "US", "residential": true, "postalCode": "95014"}, "rates": [{"serviceId": "PM", "parcelType": "PKG", "carrier": "USPS", "inductionPostalCode": "95110", "specialServices": [{"specialServiceId": "DelCon"}]}], "fromAddress": {"company": null, "phone": "5122901212", "name": "Adobe", "addressLines": ["345 Park Avenue"], "cityTown": "San Jose", "email": "[email protected]", "countryCode": "US", "stateProvince": "CA", "residential": true, "postalCode": "95110"}, "documents": [{"contentType": "URL", "fileFormat": "PDF", "type": "SHIPPING_LABEL", "size": "DOC_4X6", "printDialogOption": "EMBED_PRINT_DIALOG"}], "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
#Get International Label
curl --verbose --header "X-PB-Shipper-Rate-Plan: PP_SRP_NEWBLUE" --header "Content-Type: application/json" --header "Authorization: Bearer qM8d3q3rQtrq9p4uow5qskEKMYdg" --header "X-PB-TransactionId: ${rand_ints[11]}" --header "Accept: application/json" --data '{"documents": [{"contentType": "URL", "size": "DOC_8X11", "type": "SHIPPING_LABEL", "fileFormat": "PDF", "printDialogOption": "EMBED_PRINT_DIALOG"}], "parcel": {"dimension": {"length": 8, "width": 3, "height": 7, "unitOfMeasurement": "IN"}, "weight": {"weight": 14.0, "unitOfMeasurement": "OZ"}}, "toAddress": {"company": null, "countryCode": "GB", "residential": true, "email": "[email protected]", "phone": "5122901212", "name": "Houses of Parliament", "addressLines": ["Parliament Square"], "postalCode": "0PW", "cityTown": "London"}, "fromAddress": {"company": null, "countryCode": "US", "residential": true, "postalCode": "95110", "email": "[email protected]", "phone": "5122901212", "name": "FirstName LastName", "addressLines": ["345 Park Avenue"], "stateProvince": "CA", "cityTown": "San Jose"}, "rates": [{"specialServices": [], "carrier": "USPS", "inductionPostalCode": "95110", "parcelType": "PKG", "serviceId": "PMI"}], "customs": {"customsInfo": {"reasonForExport": "DOCUMENTS", "currencyCode": "USD", "invoiceNumber": "1234567890"}, "customsItems": [{"quantity": 1, "unitPrice": 10.0, "unitWeight": {"weight": 3.0, "unitOfMeasurement": "OZ"}, "originCountryCode": "US", "description": "a banana"}]}, "shipmentOptions": [{"name": "SHIPPER_ID", "value": "22497613"}, {"name": "ADD_TO_MANIFEST", "value": "true"}, {"name": "HIDE_TOTAL_CARRIER_CHARGE", "value": "true"}]}' --request "POST" 'https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?includeDeliveryCommitment=True'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment