1

FedEx Address Validation API is returning encoded characters and a 400 bad request error. Here is my request body with the secret key blocked out for obvious reasons:

POST /address/v1/addresses/resolve HTTP/1.1
Content-Type: application/json
x-customer-transaction-id: 
x-locale: en_US
authorization: Bearer {my secret key}
{
  "addressesToValidate": [
   {
      "address":{
         "streetLines":[
            "1234 Example Rd.",
            ""
         ],
         "city":"Morris",
         "stateOrProvinceCode":"AL",
         "postalCode":"35116",
         "countryCode":"US"
      }
   }]
}

This is what the encoded response looks like:

HTTP/1.1 400 BadRequest
Content-Type: application/json;charset=UTF-8
Content-Encoding: gzip
Connection: close
Server-Timing: cdn-cache; desc=MISS,edge; dur=115,origin; dur=62
Content-Length: 175
Date: Tue, 28 Jun 2022 18:47:56 GMT
Server: Layer7-API-Gateway
�ʱ�0�_��l�a�Ƞ���p�6�6�@B�������;2�d���+�)�$�4�B%b�L�3
W"�%�N�L��9�<���U9n7��,���REY����{j�Z�=��í�A��Z�8�L���J�Lvp��=���M@
i������ϱ

Here is the API documentation for reference: https://developer.fedex.com/api/en-us/catalog/address-validation/v1/docs.html#operation/Validate%20Address

2 Answers2

1

The answer was looking up how to decompress gzip in the language I was using. With Outsystems, I downloaded a forge component called gzip that compresses and decompresses binary to and from plaintext.

0

Sample syntax to decompress fedex api error messages in java

Public apiCall()
{

 try{
  // api call
}catch(Exception e)
{
    String errorMessage = deCompress(e.getResponseBodyAsByteArray());
}

}    


private static String deCompress(byte[] str) throws IOException{
         String decodedString= null;
         ByteArrayInputStream byteA = new ByteArrayInputStream(str);
         final GZIPInputStream gzipInput = new GZIPInputStream(byteA);
         InputStreamReader reader = new InputStreamReader(gzipInput);
         BufferedReader in = new BufferedReader(reader);
         String readed="";
         String errormessage = "";
         while ((readed = in.readLine()) != null) {  
             System.out.println(readed);
             errormessage=readed;
         }
         
        return errormessage;

    }