CORS Error for API

Hi There, I’m building an internal App to get the duty rate for a commodity code.

In my testing, I’m not able to access the API data.

Origin http://0.0.0.0:3000 is not allowed by Access-Control-Allow-Origin

Is this API not to be consumed by Javascript or Ruby, and only to be used via Browser or CURL?

Thanks!

Thanks for raising this issue, we will consider your request to add localhost to the CORS allowed origins header.

Hi Peter,

If you use the API endpoint mentions in the documentation you can request it from localhost.

https://www.trade-tariff.service.gov.uk/api/v2

Thanks,
Matt

Thanks for your help here Matt. I ended up using HTTParty in my Rails controller in the end.

Sidenote: For some reason the Base Duty rate is returned as an HTML span tag in the JSON response, so just needed to parse my way around that to get the actual % figure out