fastruby / harvesting

Ruby wrapper for the Harvest API v2
MIT License
28 stars 30 forks source link

Add RequestNotFound error #55

Closed JuannFerrari closed 4 years ago

JuannFerrari commented 4 years ago

Hi guys! thank you for developing this gem

I left here a PR https://github.com/fastruby/harvesting/pull/54 to rescue when the Harvest API returns a 404 status code to Harvesting gem.

I hope you find it useful ❤️

etagwerker commented 4 years ago

@JuannFerrari Hey, thanks for looking into it! Could you share the current behavior? What happens if we don't apply your PR?

JuannFerrari commented 4 years ago

@etagwerker Sure, no problem!

Description

When a user tries to create a new assignment in a project the gem does the next:

POST /v2/projects/{PROJECT_ID}/user_assignments

The problem is that the PROJECT_ID could be nil (in the worst-case scenario), so the response of Harvest API is an HTML body (in a string) with 404 HTTP code.

This provokes a JSONParser::Error because the gem tries to parse the string of an HTML body response