Trying to utilize fedex ship api using vba but I keep getting a response of "The given JWT is invalid. Please modify your request and try again."
Here is my json payload
{
"labelResponseOptions": "URL_ONLY",
"requestedShipment": {
"shipper": {
"contact": {
"personName": "Nick",
"phoneNumber": 3155555555,
"companyName": "company"
},
"address": {
"streetLines": [
"34 road dr"
],
"city": "saint charles",
"stateOrProvinceCode": "MO",
"postalCode": 63301,
"countryCode": "US"
}
},
"recipients": [
{
"contact": {
"personName": "Nick",
"phoneNumber": 3155555555,
"companyName": "company"
},
"address": {
"streetLines": [
"4469 Road"
],
"city": "BATON ROUGE",
"stateOrProvinceCode": "LA",
"postalCode": 70808,
"countryCode": "US"
}
}
],
"shipDatestamp": "2023-06-02",
"serviceType": "STANDARD_OVERNIGHT",
"packagingType": "FEDEX_BOX",
"pickupType": "USE_SCHEDULED_PICKUP",
"blockInsightVisibility": false,
"shippingChargesPayment": {
"paymentType": "SENDER"
},
"labelSpecification": {
"imageType": "PDF",
"labelStockType": "PAPER_85X11_TOP_HALF_LABEL"
},
"requestedPackageLineItems": [
{
"weight": {
"value": 4,
"units": "LB"
}
}
]
},
"accountNumber": {
"value": "740561073"
}
}
I have the following for the header
Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
xmlHttp.Open "POST", url, False
xmlHttp.SetRequestHeader "Authorization", "Bearer " & accessToken
xmlHttp.SetRequestHeader "Content-Type", "application/json"
xmlHttp.SetRequestHeader "Accept", "application/json"
I am getting a proper accessToken, so I'm wondering if its my format but I keep comparing it to the example and see no problem
Any help is appreciated. I can provide more code if needed.
Here is the url I am posting to: "https://apis-sandbox.fedex.com/ship/v1/shipments"
and here is the exact response I receive:
{"transactionId": "20479caf-d3d9-4a26-819c-d43f7e91c799","errors":[{"code":"BAD.REQUEST.ERROR","message":"The given JWT is invalid. Please modify your request and try again."}]}
Now I suspect that my authorization is actually to blame. in every example on FedEx's site they receive a token with the scope of "cxs". My tokens have a scope of "oob". I have also noticed I receive a token no matter what credentials I put in.
Here are the examples I am referencing: https://developer.fedex.com/api/en-us/catalog/authorization/v1/docs.html
Here is the token I receive:
{
"access_token":"826deebc-0788-4bda-995c-e1cb5b588a51",
"token_type":"Bearer",
"expires_in":3600,
"scope":"oob",
"resource": ["https://apis.fedex.com/*"]
}