Closed eluleci closed 7 years ago
Hi we have also run into this issue, is there any workaround or fix?
When I try this use-case if I send to a single recipient a
I see a normal error I expect that is the use case you are doing. Or are you sending to multiple recipients?
In the single recipient use case I see the errors->code
is being returned as a number instead of as a string:
{
"errors": [
{
"message": "At least one valid recipient is required",
"code": 5002
}
]
}
In the multiple recipient case where one is invalid this is the response from the server:
{
"errors": [
{
"message": "transmission created, but with validation errors",
"description": "message submitted for generation successfully",
"code": "2000"
}
],
"results": {
"rcpt_to_errors": [
{
"message": "invalid data format/type",
"description": "invalid recipient address.email: a",
"code": "1300"
}
],
"total_rejected_recipients": 1,
"total_accepted_recipients": 1,
"id": "66633760885560781"
}
}
And this is a standard good response for the transmission API call:
{
"results": {
"total_rejected_recipients": 0,
"total_accepted_recipients": 1,
"id": "66633760885567478"
}
}
Looking more closely at the outputs it looks like errors ->code
is sometimes encoded as a string and other times it is encoded as an int. I will talk to our server team about this and report back.
Looking at the example errors shown for the transmission api errors->code
should always be a string.
Internal tracking ID: MO-6986
We are always sending to a single recipient at this time, thanks for looking into this.
Any update on this?
We'll have to work around this inconsistency. I'll work on getting this out today or tomorrow.
Not quite today or tomorrow
, but the PR is up there, with tests showing that it handles the inconsistent input.
I am testing some cases where the emails are not valid. I used "a" as email and the SDK had error with message:
parsing api response: json: cannot unmarshal number into Go struct field SPError.code of type string
I think it's a bug in SparkPost API itself but I'm using this library so I wanted to describe it here.