Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit subscriber via API #995

Closed
ilyakonovalenko opened this issue Oct 21, 2022 · 10 comments
Closed

Edit subscriber via API #995

ilyakonovalenko opened this issue Oct 21, 2022 · 10 comments
Labels
documentation Improvements or additions to documentation

Comments

@ilyakonovalenko
Copy link

Hello,

Can you please let me know how to edit subscriber via API? It is not currently documentated and I was not able to find a way.

I tried to use PUT method with attribs to change, however, API always returns:

Unmarshal type error: expected=models.SubscriberAttribs, got=array, field=attribs, offset=12

I also tried to pass double-quoted json raw data (as used in import), but it also fails with:

Unmarshal type error: expected=models.SubscriberAttribs, got=string, field=attribs, offset=32
@knadh knadh added the documentation Improvements or additions to documentation label Oct 22, 2022
@knadh
Copy link
Owner

knadh commented Oct 22, 2022

Looks like this is indeed missing in the docs. You can send the same payload as subscriber creation and send a PUT request to /api/subscribers/:id

@ilyakonovalenko
Copy link
Author

ilyakonovalenko commented Oct 22, 2022

That is what I tried as well. Creation API works fine, but edit API returns an error I mentioned. I also tried to skip attribs parameter, however, it does not work as well :-(

Full payload is:

{"attribs":[{"cid":"123"}],"name":"Name Lastname"}

@knadh
Copy link
Owner

knadh commented Oct 22, 2022

attribs should always be a map, not an array. Here, it should be:

{"attribs": {"cid":"123"}, "name":"Name Lastname"}

@ilyakonovalenko
Copy link
Author

attribs should always be a map, not an array.

Yeah. Changed it already. It seems the endpoint needs all params to be passed. Can you please implement PATCH endpoint or adjust PUT endpoint to only edit data passed in payload?

@knadh
Copy link
Owner

knadh commented Oct 22, 2022

Ah yes, that's correct.

Can you please implement PATCH endpoint or adjust PUT endpoint to only edit data passed in payload?

Will look into this.

marcinkunert added a commit to marcinkunert/listmonk that referenced this issue Mar 31, 2023
I've expanded the docs a bit, related to knadh#995
knadh pushed a commit that referenced this issue Apr 2, 2023
I've expanded the docs a bit, related to #995
@Pseudoman21
Copy link

That is what I tried as well. Creation API works fine, but edit API returns an error I mentioned. I also tried to skip attribs parameter, however, it does not work as well :-(

Full payload is:

{"attribs":[{"cid":"123"}],"name":"Name Lastname"}

Hi! I know this is a long time ago but I can I ask help on adding subscriber using the API? Thank you so much!

@ilyakonovalenko
Copy link
Author

Hi! I know this is a long time ago but I can I ask help on adding subscriber using the API? Thank you so much!

Hello! Can you please share what your issue is?

@Pseudoman21
Copy link

Hi! I know this is a long time ago but I can I ask help on adding subscribers using the API? Thank you so much!

Hello! Can you please share what your issue is?

Hi! I am trying to add a subscriber using Postman before implementing it in the backend but it always responds with an unauthorized error.

@Pseudoman21
Copy link

Pseudoman21 commented Apr 25, 2023

Hi! I know this is a long time ago but I can I ask help on adding subscriber using the API? Thank you so much!

Hello! Can you please share what your issue is?

Hi! I've finally made it work. Thank you ^^

@knadh
Copy link
Owner

knadh commented Dec 30, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants