Closed c-nv-s closed 1 year ago
Hello @c-nv-s
The 422 response from the backend means there is a validation error with the provided data.
By looking at the sample you provider, it seems to be because the API is expecting the Country
to be an ISO 3166 (alpha-2) and not a country name.
You can see it in our API documentation: https://doc.getlago.com/api-reference/customers/create
The error from the service should contain the reason for the 422. We will investigate on it to make ensure error response are clear.
you are correct that the format of the country was wrong, however the actual lago.Error
was empty/nil
so I couldn't even determine what was causing the issue :-(
Indeed, the current implementation of the error handling does not match the format of the error sent by the API.
A fix for this problem has just been opened at https://github.com/getlago/lago-go-client/pull/108. It will probably be part of the next release
I'm closing this issue as it is "fixed"
Describe the bug The Create Customer function is constantly failing with
422
error code I have also noticed that it doesn't seem to be executing the same sql as when the equivalentcurl
command is used to create a customer. Also not that if fails regardless of whether settingsync
orsync_with_provider
totrue
.To Reproduce
example go code (you will note that the go code shown at https://docs.getlago.com/api-reference/customers/create does not work because the
Metadata
value is incorrectly formatted, and also theVatRate
field is missing a comma at the end of the line)produces example sql log (notice that no stripe customer creation task/job is first created as seen in the subsequent curl example)
example
curl
commandproduces the following sql in the logs (notice the stripe customer creation job is also created first as well as the difference in sql)
Expected behavior The customer should be created in both lago and stripe as is the case when using a
curl
requestSupport
Additional context Not sure if it makes a difference but when checking the differences in the http requests between the go client and curl. the go client has headers
Accept: application/json, Accept-Encoding: gzip
whereas curl just usesAccept: */*
with no specified Encoding preference either