Search code examples
javaspring-bootmaveneasypost

Expected a string but was BEGIN_OBJECT at line 1 column 123 path $.options in easypost shipment


I am integrating the shipment in my application using easy post API when I use shipment.create(shipmentMap, EASYPOSTAPIKEY) it's throwing an error Expected a string but was BEGIN_OBJECT at line 1 column 123 path $.options.

Map<String, Object> parcelMap = new HashMap<String, Object>();
parcelMap.put("predefined_package", "FlatRateEnvelope");
parcelMap.put("weight", 10);
Parcel parcel = Parcel.create(parcelMap);
Map<String, Object> shipmentMap = new HashMap<String, Object>();
shipmentMap.put("to_address", toAddress);
shipmentMap.put("from_address", fromAddress);
shipmentMap.put("parcel", parcel);
Shipment shipment = Shipment.create(shipmentMap, EASYPOSTAPIKEY);

java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 123 path $.options.at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[gson-2.8.5.jar:na]


Solution

  • Updating the latest version of easy post client API should fix this.