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

creat new list got error 404:Exception raised: API error 404 when requesting https://apiv3.emailsys.net/v1/recipientlists. Detail: <html> #13

Closed
pedramham opened this issue Mar 23, 2023 · 6 comments
Labels
api-bug Bugs relating to the API rather than the client

Comments

@pedramham
Copy link

Hello
For getting a list of emails from the recipientlists or adding an item to an existing list, everything works correctly.

        ///test get list recipient
        $listService = $client->recipientlists();

        foreach ($listService->query() as $list) {
            var_dump($list);
        }

        $recipientsService = $client->recipients();
        $recipientsService->create(
        // Dataset: Represents the recipient dataset you're creating
            [
                'recipientlist_id' => $list['id'], // Required
                'email' => 'td5474@thapke.de', // Required
                'firstname' => 'Test first name',
                'lastname' => 'Test last name',
                'gender' => 'male',
                'status' => "active"
            ],
        );

But when I try to use the recipientlists method to create a new list I got an error

        $serviceCreate = $client->recipientlists();
        try {
        $response = $serviceCreate->create([
            [
                'name' => 'test', // Required
                'description' => 'test create list', 
                'unsubscribe_blacklist' => 'no',
                'recipient_subscribe_email' => 'no',
                'default' => 'no',
            ],
        ]);
            die($response);
        } catch (ApiClientException $e) {
            echo "Exception raised: " . $e->getMessage();

        }

I got error 404

Exception raised: API error 404 when requesting https://apiv3.emailsys.net/v1/recipientlists. Detail: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
@eth8505
Copy link
Collaborator

eth8505 commented Mar 23, 2023

Hello @pedramham.

I tried to reproduce this issue, but could not. Can you try to verify again if the issue persists? For me it works as expected with our test accounts and credentials. I saw that you already contacted our customer support directly. Please let them know which account you're working with so i can trace this further. Please do not post any account details or credentials here though :)

Best wishes
Jan

@pedramham
Copy link
Author

pedramham commented Mar 23, 2023 via email

@eth8505
Copy link
Collaborator

eth8505 commented Mar 23, 2023

@pedramham demo mode shouldn't affect your access to the API. This is especially awkward behavior as it seems to respond as HTML. The API should always return JSON responses though.
I may have found the cause though, found an exception from around the time you created your ticket concerning recipientlist creates via the API. Will look into it and get back to you.

Regarding your query question: Filtering lists by name is currently not supported.

@eth8505
Copy link
Collaborator

eth8505 commented Mar 23, 2023

@pedramham we have identified the issue. It appears that under certain circumstances the API client generates an invalid request body. Working on a fix.

@eth8505 eth8505 added the client-bug Something isn't working in the client label Mar 23, 2023
@eth8505
Copy link
Collaborator

eth8505 commented Mar 24, 2023

@pedramham i just noticed where the actual issue lies, it's not the client afterall, you simply have an additional array level in your code:

$serviceCreate = $client->recipientlists();
        try {
        $response = $serviceCreate->create([
                'name' => 'test', // Required
                'description' => 'test create list', 
                'unsubscribe_blacklist' => 'no',
                'recipient_subscribe_email' => 'no',
                'default' => 'no',
        ]);
            die($response);
        } catch (ApiClientException $e) {
            echo "Exception raised: " . $e->getMessage();

        }

This is how your code should look - this will work.

I did however identify a bug on the server-side causing wrong responses if data like this is posted. Will be deploying a fix for it this morning.

@eth8505 eth8505 closed this as completed Mar 24, 2023
@eth8505 eth8505 added api-bug Bugs relating to the API rather than the client and removed client-bug Something isn't working in the client labels Mar 24, 2023
@nielsnuebel
Copy link

@eth8505 did you use nginx or apache? I have the same issues with nginx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-bug Bugs relating to the API rather than the client
Projects
None yet
Development

No branches or pull requests

3 participants