Documentation

Errors

Every refusal is an RFC 9457 problem, sent as application/problem+json:

JSONCode
{ "type": "https://developers.fincalc.com/problems/not-licensed", "title": "Calculator not licensed", "status": 403, "detail": "Your license does not include auto-loan-accelerated-payoff for the API." }

Code against type, never detail: the detail is for people and may change. Each type is a page here that says what it means and what to do.

A 429 or 503 carries Retry-After, in seconds. Wait at least that long; retrying sooner only spends your rate limit.

Reading a refusal's body

Some HTTP clients treat a 4xx as an exception and keep the body out of sight, and the body is what says what to fix. In Windows PowerShell 5.1, Invoke-RestMethod and Invoke-WebRequest throw on a 4xx: read the problem from the error record, $_.ErrorDetails.Message, in a catch block. PowerShell 7 can keep the answer instead, with -SkipHttpErrorCheck and -StatusCodeVariable:

Code
$answer = Invoke-RestMethod https://api.fincalc.com/v2/calculators/auto-loan-accelerated-payoff ` -Method Post -Headers @{ Authorization = "Bearer $env:FINCALC_KEY" } ` -ContentType "application/json" -Body '{"loanAmount": 25000}' ` -SkipHttpErrorCheck -StatusCodeVariable status if ($status -ge 400) { $answer.type; $answer.detail; $answer.errors }

curl prints the body whatever the status; add --fail-with-body to make it fail the command too.

Last modified on