EasyPost / easypost-java

EasyPost Shipping API Client Library for Java
https://easypost.com/docs/api
MIT License
53 stars 37 forks source link

[Bug]: USPS buy Pickup API call throwing error "Invalid name. Please check for any special characters." #303

Closed k0m09dx closed 4 months ago

k0m09dx commented 6 months ago

Software Version

7.1.0

Language Version

17

Operating System

Ubuntu Linux

What happened?

  1. Create Pickup Request for USPS.
  2. From the response object select the respective Carrier and Service name to make buy Pickup api call.
  3. Getting error as "Invalid name. Please check for any special characters." ...

What was expected?

Expected that Error objects should specify that the error property name for that the API call is failing instead of the generic fallback of "Invalid name. Please check for any special characters."

Sample Code

Map<String, Object> requestPayload =  new HashMap<>();
requestPayload.put("carrier", "USPS");
requestPayload.put("service", "NextDay");

client.pickup.buy(pickupId, requestPayload);

Relevant logs

CODE = PICKUP.BUY.FAILED
MESSAGE = Invalid name. Please check for any special characters.

StackTrace:
com.easypost.exception.API.BadRequestError: Invalid name. Please check for any special characters.
    at com.easypost.http.Requestor.handleAPIError(Requestor.java:676)
    at com.easypost.http.Requestor.httpRequest(Requestor.java:610)
    at com.easypost.http.Requestor.request(Requestor.java:504)
    at com.easypost.http.Requestor.request(Requestor.java:448)
    at com.easypost.service.PickupService.buy(PickupService.java:121)
Justintime50 commented 6 months ago

Hey @k0m09dx, thanks for writing in. Is the carrier and service provided above the only thing present in the requestPayload? What is the pickupId you are using? Are there any additional pieces of sample code you could share that hasn't been yet that may help us in reproducing this issue?

k0m09dx commented 6 months ago

Hi @Justintime50 I followed the steps mentioned in the Doc .FYR: https://www.easypost.com/docs/api/java#buy-a-pickup. Language: Java(17). you can try the same with below Id Environment: test Pickup Id: pickup_2861e54ae5ba413baa9ce785f4ca634b Shipment Id: shp_9e76a9a04e234b4a8248d6f61da3c55b

Justintime50 commented 6 months ago

What happens if you try with a new shipment that has a corrected address "name" field? It appears there is a 2 in the name field which may be leading to this error with USPS? See Koushik2 Mondal in the response. Let me know if that works as expected once corrected.

k0m09dx commented 4 months ago

Sorry for the delayed response. the above issue fixed.