I faced this issue from last week and found solution finally after a discussion with FedEx Technical Person.See why we are facing such error all because of Developer Test Account we generated from developer website.One thing we should keep in mind that Test Account Number start with "6" is of Production & Key Start with "5" is Correct Test Key.So Please check your Test Key when you get Authentication problem with Error Code 1000.
Revert me if this is not helpful.
Answer from Amarn on Stack OverflowHi all,
I am currently using the Fedex API to integrate their services into our software. Their entire testing environment has been virtualized, so you get basically no usefull testing capabilities. I am able to upload documents using their "Trade Documents Upload API", which works just fine, but when trying to connect these documents to the shipment I am suddenly getting a 400 error: "SHIPMENT.ACCOUNTNUMBER.UNAUTHORIZED", with a message saying they cannot retrieve the error message. The only difference between a passing request and a failing request here is the inclusion of "shipmentSpecialServices", doing it exactly like they tell you to do it in the upload document docs.
This is using a pre-shipment document upload setup
Does anyone have any experience with this?
java - FEDEX API, Authentication Failed - Stack Overflow
FedEx API Request Failing with 422 Error - Invalid Field Value
php - Fedex API giving error value for rates - Stack Overflow
php - FEDEX Shipping Rate API Error Msg: 'Account number not found.' - Stack Overflow
I faced this issue from last week and found solution finally after a discussion with FedEx Technical Person.See why we are facing such error all because of Developer Test Account we generated from developer website.One thing we should keep in mind that Test Account Number start with "6" is of Production & Key Start with "5" is Correct Test Key.So Please check your Test Key when you get Authentication problem with Error Code 1000.
Revert me if this is not helpful.
https://www.xadapter.com/test-use-fedex-account-number-test-account-number-password-use/
User Account Password is different from password we have to supply in web service. please check above link
Hi all,
I'm working on integrating the FedEx API to fetch shipping rates but encountering persistent 422 errors. The error message states "Invalid field value in the input," but I'm struggling to identify which field is causing the issue.
Whenever I send a request to the FedEx API, I receive a 422 error response with the message "Invalid field value in the input." Below are the details of my request payload and the server response.
Request Payload
{
"accountNumber": {
"value": "123456789"
},
"requestedShipment": {
"shipDateStamp": "2024-07-04",
"pickupType": "USE_SCHEDULED_PICKUP",
"serviceType": "FEDEX_ECONOMY_SELECT",
"packagingType": "YOUR_PACKAGING",
"totalWeight": {
"units": "KG",
"value": 11
},
"shipper": {
"address": {
"streetLines": ["123 Origin St"],
"city": "Deeide",
"postalCode": "CH5 2UA",
"countryCode": "GB"
}
},
"recipient": {
"address": {
"streetLines": ["456 Destination Ave"],
"city": "Reading",
"postalCode": "RG2 9YE",
"countryCode": "GB"
}
},
"rateRequestType": ["ACCOUNT"],
"requestedPackageLineItems": [
{
"groupPackageCount": "1",
"weight": {
"units": "KG",
"value": 1
},
"dimensions": {
"length": 10,
"width": 10,
"height": 10,
"units": "CM"
}
},
{
"groupPackageCount": "1",
"weight": {
"units": "KG",
"value": 10
},
"dimensions": {
"length": 10,
"width": 10",
"height": 10,
"units": "CM"
}
}
]
},
"rateRequestControlParameters": {
"returnTransitTimes": true
}
}Error Response
{
"transactionId": "31504e25-a8d5-458d-a624-262cb7e06706",
"errors": [
{
"code": "INVALID.INPUT.EXCEPTION",
"message": "Invalid field value in the input"
}
]
}Code
Here is the JavaScript code I'm using to send the request:
const fetch = require('node-fetch');
const FEDEX_API_URL = 'https://apis.fedex.com/rate/v1/rates/quotes';
const FEDEX_ACCOUNT_NUMBER = '123456789';
async function getFedexRates(token, serviceType, shipmentDetails) {
const currentDate = new Date().toISOString().split('T')[0];
const packages = shipmentDetails.packages.map((pkg) => ({
groupPackageCount: '1',
weight: {
units: 'KG',
value: pkg.weight
},
dimensions: {
length: pkg.length,
width: pkg.width,
height: pkg.height,
units: 'CM'
}
}));
const fedexRequest = {
accountNumber: {
value: FEDEX_ACCOUNT_NUMBER
},
requestedShipment: {
shipDateStamp: currentDate,
pickupType: 'USE_SCHEDULED_PICKUP',
serviceType: serviceType,
packagingType: 'YOUR_PACKAGING',
totalWeight: {
units: 'KG',
value: shipmentDetails.packages.reduce((acc, pkg) => acc + pkg.weight, 0)
},
shipper: {
address: {
streetLines: [shipmentDetails.originAddress],
city: shipmentDetails.originCity,
postalCode: shipmentDetails.originPostcode,
countryCode: shipmentDetails.originCountry
}
},
recipient: {
address: {
streetLines: [shipmentDetails.destinationAddress],
city: shipmentDetails.destinationCity,
postalCode: shipmentDetails.destinationPostcode,
countryCode: shipmentDetails.destinationCountry
}
},
rateRequestType: ['ACCOUNT'],
requestedPackageLineItems: packages
},
rateRequestControlParameters: {
returnTransitTimes: true
}
};
console.log('FedEx Request:', JSON.stringify(fedexRequest, null, 2));
try {
const response = await fetch(FEDEX_API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-locale': 'en_US',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(fedexRequest)
});
const responseBody = await response.text();
console.log('FedEx Response Status:', response.status);
console.log('FedEx Response Body:', responseBody);
if (!response.ok) {
throw new Error(`FedEx API request failed with status ${response.status}: ${responseBody}`);
}
const fedexData = JSON.parse(responseBody);
return fedexData;
} catch (error) {
console.error(`Error fetching data for service type ${serviceType}:`, error.message);
return null;
}
}
module.exports = { getFedexRates };What could be causing the 422 error with the message "Invalid field value in the input"?
Are there any specific fields or values that need to be adjusted for this request to succeed?
Any help or guidance on this issue would be greatly appreciated!
Two things caught my attention with your request:
- The recipient address doesn't contain a state value. I'm not completely sure whether it's required by FedEx, but many carriers do require the state code.
- The package dimensions are 100x100x100. According to http://images.fedex.com/us/services/pdf/packaging/GrlPkgGuidelines_fxcom.pdf, this exceeds the max. girth restriction and thus you would need to use FedEx Freight, which is a different API. This would explain the "no valid services" error.
For me, issue was that the FedexRateServiceRequest requires Zip, CountryCode AND State. Without state I got the same error.
rate_request.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'CA'
Use valid values for includeDetailedScans: True/ False. Then serialize the payload, and will be fine.
authoriztion_key = get_oauth()
url = f"{sandbox_url}/track/v1/trackingnumbers"
headers = {
'Content-Type': "application/json",
'x-locale': "en_US",
'Authorization': f'Bearer {authoriztion_key}'
}
payload = {
"trackingInfo": [
{
"trackingNumberInfo": {
"trackingNumber": f"{tracking_number}"
}
}
],
"includeDetailedScans": True
}
payload = json.dumps(payload)
response = requests.post(url, data=payload, headers=headers)
includeDetailedScans:Indicates if detailed scans are requested or not. Valid values are True, or False.
Did you try giving it a boolean value instead of an int?