These docs are for v1.0. Click to read the latest docs for v2024.09.

Discussions

Ask a Question
Back to All

2-Way API Call

Hi,

I have an upgraded easyship account and I need to make recurring 2-way api calls between freshdesk api and easyship api. This is an actual example of the api call to easyship from a freshdesk sales agent for my company to retrieve shipping rates for a customer order:

POST /2023-01/rates HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer prod_k31AsLGnjnDLBwvRQXCozN6EQ0eic6aG88lA7LWc42I=
Host: api.easyship.com
Content-Length: 987

{"origin_address":{"line_1":"13734 Bermuda Cay Ct","state":"FL","city":"Jacksonville","postal_code":"32225","country_alpha2":"US","company_name":"Quick Shaver LLC","contact_name":"Attn Wes Krosnick","contact_phone":"9043801159","contact_email":"[email protected]"},"destination_address":{"line_1":"19 Gaywood Cr","state":"AL","city":"Birmingham","postal_code":"36213","contact_name":"George Brown","contact_phone":"‭9045531910‬","country_alpha2":"US"},"insurance":{"is_insured":false},"courier_selection":{"apply_shipping_rules":true},"shipping_settings":{"units":{"weight":"lb","dimension":"in"},"output_currency":"USD"},"parcels":[{"box":{"slug":"bubble-shipping-bag","length":17,"width":9,"height":4},"items":[{"quantity":1,"dimensions":{"length":11,"width":9,"height":4},"description":"Electric Shaver","category":"health_beauty","sku":"QS-3300","hs_code":"8510.10.00","origin_country_alpha2":"US","declared_currency":"USD","declared_customs_value":59.95}],"total_actual_weight":2}]}

This is the api call to freshdesk from easyship in direct and immediate response to the above api call. It updates my agent's shipping dropdown menu options in his sales ticket to give the customer his shipping courier and rate options from inside the freshdesk interface:

curl -v -u MYAPIKEY:X -H "Content-Type: application/json" -X PUT -d '{ "label_for_customers":"Shipping", "label":"Shipping", "position": 17, "choices":[{ "deleted":true,"id":53 },{ "deleted":true,"id":54 },{ "deleted":true,"id":55 },{ "value":"$5.08 - USPS Priority - 2-10 days", "position":1 },{ "value":"$7.82 - USPS Media - 2-3 days", "position":2 },{ "value":"$15.08 - UPS Ground - 3 days", "position":3 }] }' 'https://MYDOMAIN.freshdesk.com/api/v2/admin/ticket_fields/151000699500'

This requires some custom coding to insert data from the easyship api response data into this freshdesk api call and also requires the persistent storage of field id numbers in the call to increment them each time the api call is made.

Are you able and willing to do this?