listmonk icon indicating copy to clipboard operation
listmonk copied to clipboard

Subscriber update via API fails

Open BenBao93 opened this issue 5 years ago • 5 comments

I am unable to update subscribers via the PUT endpoint /api/subscribers/:id. Regardless of the actual body the endpoint always returns a 200 response with no updates performed.

Issue #237 seems to be about the same problem.

Generally is the PUT endpoint supposed to merge/override new data or does all subscriber data need to be sent again + the additional/update data?

BenBao93 avatar Mar 09 '21 12:03 BenBao93

Issue #237 unfortunately doesn't provide any context. I just responded with an example there.

Generally is the PUT endpoint supposed to merge/override

Whatever field is sent is merged into the record. You needn't send the whole payload again.

knadh avatar Mar 09 '21 12:03 knadh

I inspected the request from the UI, I think the issue was missing id property in body. I assumed since it is in the endpoint path it doesn't need to be in the body. Once I added id to the JSON body it works fine.

BenBao93 avatar Mar 09 '21 12:03 BenBao93

Ah! That's a subtle bug. Fixed: https://github.com/knadh/listmonk/commit/f8e555dac5451d338be42966835f33355af08a2b

knadh avatar Mar 09 '21 12:03 knadh

Issue #237 unfortunately doesn't provide any context. I just responded with an example there.

Generally is the PUT endpoint supposed to merge/override

Whatever field is sent is merged into the record. You needn't send the whole payload again.

@knadh Thanks for support and fixing this so fast! Just one follow-up on the payload. From my tests it looks like attribs will not be merged but new value overrides old, is that expected?

BenBao93 avatar Mar 09 '21 18:03 BenBao93

Fixed this behaviour as well: https://github.com/knadh/listmonk/commit/e8ad7a9adcbc7a268e0dbba6b217268bb210df46

This'll be available in the upcoming release this weekend.

knadh avatar Mar 10 '21 15:03 knadh