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

Unable to change limit on Webhook calls method #154

Closed
haydnsimons opened this issue Aug 19, 2022 · 8 comments
Closed

Unable to change limit on Webhook calls method #154

haydnsimons opened this issue Aug 19, 2022 · 8 comments

Comments

@haydnsimons
Copy link

haydnsimons commented Aug 19, 2022

Hello,

I've just updated to SDK version 3.4.4 following the fix for this issue #149. I am now trying to use the SDK to retrieve a list of webhook calls with a specified limit. As far as I can see, this functionality isn't possible for webhook calls as you can't pass in a query parameter (unlike how it can be done in the webhooks fetchAll method). I have pasted a simple java application below to show how it works for the fetchAll method but how it's not possible for the calls method.

import com.contentful.java.cma.CMAClient;
import com.contentful.java.cma.model.CMAArray;
import com.contentful.java.cma.model.CMAWebhook;

public class Application {
private final static String TOKEN = "PERSONAL_ACCESS_TOKEN";
private final static String SPACE = "SPACE_ID";

public static void main(String[] args) {
	CMAClient client = new CMAClient
			.Builder()
			.setAccessToken(TOKEN)
			.setSpaceId(SPACE)
			.build();


        //CAN successfully limit number of webhooks returned from this call by populating the 'query' parameter.
        CMAArray<CMAWebhook> array = client.webhooks().fetchAll(SPACE_ID, query);

        //Fetch the webhook for the space and id.
        final CMAWebhook webhook = client.webhooks().fetchOne(SPACE_ID, WEBHOOK_ID);

        //Fetch all the call for a specific webhook (would like to specify a limit for this call)
        //CANNOT limit the number of calls returned and it always defaults to a limit of 20
        final CMAArray<CMAWebhookCall> calls = client.webhooks().calls(webhook);

        //Ideally this would also have accept a second 'query' parameter (Map<String, String>) as shown below
        final CMAArray<CMAWebhookCall> calls = client.webhooks().calls(webhook, query);
    }

}

Is this functionality something that could be added to the SDK?
Thanks in advance!

@amartinez-forrester
Copy link

amartinez-forrester commented Sep 9, 2022

Same problem here. We are using a custom Web Client to "temporally" solve this problem.
Apart from that, the webhook endpoint is not working well, you need to call /health endpoint first to see the number of actual calls there.
The default "total" result is buggy and by default has "20", even if you have more calls in the buffer.
Call to /heatlh endpoint example:

{
    "sys": {
        "id": "myId",
        "type": "Webhook",
        "space": {
            "sys": {
                "type": "Link",
                "linkType": "Space",
                "id": "mySpace"
            }
        },
        "createdBy": {
            "sys": {
                "type": "Link",
                "linkType": "WebhookDefinition",
                "id": "myWebhook"
            }
        }
    },
    "calls": {
        "total": 500,
        "healthy": 294
    }
}

And when you hit /calls endpoint, the total count has always the "limit" value:
image

Summarizing, we have two problems that need a solution:

  1. Fix the total field in the response that comes from the /calls endpoint, in my example, this number should be "500", not "30".
  2. Add the feature that @haydnsimons is asking to avoid using a custom web client.

Regards,
Agustin

@rafalniski
Copy link
Collaborator

Hey @haydnsimons
This should be resolved in: #158
I will make a new release soon.

@amartinez-forrester
I raised the issue with the Contentful API team, will let you know when I have some feedback.

@rafalniski
Copy link
Collaborator

@haydnsimons This is now available in v.3.4.6

@amartinez-forrester
Copy link

Thank you @rafalniski

@haydnsimons
Copy link
Author

Thanks @rafalniski!

@amartinez-forrester
Copy link

@rafalniski Hi, did the contentful api team solve the API problem? (the total field in the response that comes from the /calls endpoint)

@rafalniski
Copy link
Collaborator

Hey @amartinez-forrester, I was told it should be fixed now. Can you check if it works correctly on your side, please?

@amartinez-forrester
Copy link

It is working, great. Thanks!

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

3 participants