N8n giving error in API, and postman working fine, can't understand it

I’m trying my best to understand this API error. I think there’s something wrong with the N8N.

I tested it on the postman and everything works fine, but on the N8N it keeps giving me this error with the same settings.





This is the new api_key


This is a test api, I’ll generate another one as soon as it goes into production.

These are my settings on the N8N, in the http Request:

It should work!

I went to check the log of my server, where my site is hosted.

And to my surprise, in the log. It’s showing that the http request was executed correctly.

Still, I keep getting this api error, but the api is correct.


Can someone give me some light?


Hi @denverfix, I am sorry you’re having trouble.

I just tried re-creating the request from your Postman screenshot on my own n8n instance but did not run into any trouble here. I am getting the expected 200 response with the HTML for your login form from your server (which seems to be exactly what you’re seeing in Postman):

This was the workflow I was using here:

Perhaps there were simply some field names/values mixed up somewhere?

Hi @MutedJam , thanks for your help.

I’ve already tried it this way, and it only shows that the form server has been authenticated.

But even if I give it code 200, it doesn’t recognize the API and doesn’t register the user on the site.

I’ve racked my brains.

The only documentation for the plugin to register users on the site is this one:

### create_user (create if not exists, else update existing Users/Members)

$op["op"] = "create_user"; // The Remote Operation.

$op["api_key"] = "296c096b6ac5c87d36b606842c76d6c2"; // Check your Dashboard for this value.
    // See: `s2Member → API / Scripting → Remote Operations API → API Key`

$op["data"] = array(
    "user_login" => "johndoe22", // Required. A unique Username. Lowercase alphanumerics/underscores.
    "user_email" => "[email protected]", // Required. A valid/unique Email Address for the new User.

    // These additional details are 100% completely optional.

    "modify_if_login_exists" => "1", // Optional. Update/modify if ``user_login`` value already exists in the database?
        // A non-zero value tells s2Member to update/modify an existing account with the details you provide, if this Username already exists.

    "user_pass" => "456DkaIjsd!", // Optional. Plain text Password. If empty, this will be auto-generated.

    "first_name" => "John", // Optional. First Name for the new User.
    "last_name" => "Doe", // Optional. Last Name for the new User.

    "s2member_level" => "2", // Optional. Defaults to Level #0 (a Free Subscriber).
    "s2member_ccaps" => "music,videos", // Optional. Comma-delimited list of Custom Capabilities.

    "s2member_registration_ip" => "123.456.789.100", // Optional. User's IP Address. If empty, s2Member will fill this upon first login.

    "s2member_subscr_gateway" => "paypal", // Optional. User's Paid Subscr. Gateway Code. One of: (paypal|alipay|authnet|ccbill|clickbank|google).
    "s2member_subscr_id" => "I-DJASODJF8933J", // Optional. User's Paid Subscr. ID. For PayPal®, use their Subscription ID, or Recurring Profile ID.

    "s2member_custom" => "s2member.dev", // Optional. If provided, should always start with your installation domain name (i.e., $_SERVER["HTTP_HOST"]).

    "s2member_auto_eot_time" => "2030-12-25", // Optional. Can be any value that PHP's ``strtotime()`` function will understand (i.e., YYYY-MM-DD).

    "custom_fields" => array("my_field_id" => "Some value."), // Optional. An array of Custom Registration/Profile Field ID's, with associative values.

    "s2member_notes" => "Administrative notation. Created this User via API call.", // Optional. Administrative notations.

    "opt_in" => "1", // Optional. A non-zero value tells s2Member to attempt to process any List Servers you've configured in the Dashboard area.
        // This may result in your mailing list provider sending the User/Member a subscription confirmation email (i.e., ... please confirm your subscription).

    "notification" => "1", // Optional. A non-zero value tells s2Member to email the new User/Member their Username/Password.
        // The "notification" parameter also tells s2Member to notify the site Administrator about this new account.
$post_data = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => 's2member_pro_remote_op='.urlencode(json_encode($op)))));
$result    = json_decode(trim(file_get_contents('https://jason.wpsharks.net/?s2member_pro_remote_op=1', false, $post_data)), true);

if ($result && empty($result['error']) && !empty($result['ID'])) {
    echo 'Success. New user created with ID: '.$result['ID'];
} elseif (!empty($result['error'])) {
    echo 'API error reads: '.$result['error'];

And this is a new API_KEY that I’ve just generated, in case anyone wants to do some tests.


I’ve already checked everything I could.

I’ll keep trying and one day I’ll find a solution.

Thank you!

Hi @denverfix, the documentation looks like it describes a request different from the one on your Postman screenshot. I don’t know PHP too well, but I think this would be the n8n representation of the request made here:

The result sure looks different now :smile::

Perhaps you can give this a go on your end?

@MutedJam You are a genius.

Now it seems to work fine, the user has been registered.

I don’t know why the documentation is like that.

I didn’t do it the way you did, I even thought about it but thought it wouldn’t work.

How did you reach that conlucsion?

I’ll do the tests.


1 Like

Glad to hear this works. I was mostly googling how PHP works, trying to understand the data structure your example code was building.

Let me know if you run into any further trouble with this :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.