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

How to PATCH / PUT campaign via API? #276

Open
dompie opened this issue Mar 18, 2024 · 6 comments
Open

How to PATCH / PUT campaign via API? #276

dompie opened this issue Mar 18, 2024 · 6 comments

Comments

@dompie
Copy link
Contributor

dompie commented Mar 18, 2024

Hello, I try to PATCH a campaign field (e.g. subject). But it results in an "Internal server error" when using swagger API. The result is also the same for PUT method.

Screenshot 2024-03-18 at 15-32-40 Swagger UI

Any suggestions?

@wmnnd
Copy link
Contributor

wmnnd commented Mar 18, 2024

Could you share the logs from your Keila instance?

@dompie
Copy link
Contributor Author

dompie commented Mar 18, 2024

Where can I find the logs? I'm not into Elexir app architecture...

@wmnnd
Copy link
Contributor

wmnnd commented Mar 18, 2024

How are you running Keila? The logs are outputted to stdout by the application when you run it.

@dompie
Copy link
Contributor Author

dompie commented Mar 18, 2024

I'm running it in the docker container. Found the logs:

18:41:34.579 request_id=F73v-vOvJ_7jlmgAAbih [info] PATCH /api/v1/campaigns/nmc_Mvg6QDVZ
18:41:34.585 request_id=F73v-vOvJ_7jlmgAAbih [info] Sent 500 in 5ms
18:41:34.586 [error] #PID<0.14628.0> running KeilaWeb.Endpoint (connection #PID<0.14627.0>, stream id 1) terminated
Server: keila.local:4000 (http)
Request: PATCH /api/v1/campaigns/nmc_Mvg6QDVZ
** (exit) an exception was raised:
    ** (ArgumentError) could not put/update key :id on a nil value
        (elixir 1.15.7) lib/access.ex:419: Access.get_and_update/3
        (elixir 1.15.7) lib/map.ex:957: Map.get_and_update/3
        (elixir 1.15.7) lib/kernel.ex:2817: Kernel.put_in/3
        (keila 0.14.0) lib/keila_web/api/controllers/api_campaign_controller.ex:83: KeilaWeb.ApiCampaignController.update/2
        (keila 0.14.0) lib/keila_web/api/controllers/api_campaign_controller.ex:1: KeilaWeb.ApiCampaignController.action/2
        (keila 0.14.0) lib/keila_web/api/controllers/api_campaign_controller.ex:1: KeilaWeb.ApiCampaignController.phoenix_controller_pipeline/2
        (phoenix 1.6.11) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
        (keila 0.14.0) lib/keila_web/endpoint.ex:1: KeilaWeb.Endpoint.plug_builder_call/2

I have also double-checked on campaigns index the given id exists.

Best regards

@wmnnd
Copy link
Contributor

wmnnd commented Mar 19, 2024

Could you try providing {"settings": {}} as part of the campaign object? This might fix the issue for now until I'm able to add a proper fix.

@dompie
Copy link
Contributor Author

dompie commented Mar 19, 2024

Yes, providing "settings": {}" attribute allows saving (although settings will reset to settings: {type: text}) - but works for me now.

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

No branches or pull requests

2 participants