As the matter of fact /users.json was working yesterday and created the new accounts through Node.js so somehow it has existed. For the admin/users.json I get following return:
{ status: 404, error: ‘Not Found’ }
I’ve even regenerated a new API key and still the same result.
I’m a bit lost here to be honest, no idea why this behavior started, I mean I could take a backup and rebuild Discourse just to see if that will fix it, but it seems like a drastic measure.
Oh I see, you are trying to create users, not list them. In that case ignore my previous post
If you visit <discourse-url>/users.json in your browser, it will return that “not found” error. That is to be expected. Sending a POST request to that URL, along with all the necessary parameters, should work fine. The docs for the endpoint are here: Discourse API Docs
I am using the exact same code as I quoted in the OP, which yesterday gave following response:
{ success: true,
active: true,
message:
'Thanks for signing up. We will notify you when your account has been approved.',
user_id: 5 }
And today I’m faced with this;
{ FetchError: invalid json response body at <discourse-url>/users reason: Unexpected end of JSON input
at C:\Users\ka0sdev\NodeRobot\node_modules\node-fetch\lib\index.js:241:32
at processTicksAndRejections (internal/process/next_tick.js:81:5)
message:
'invalid json response body at <discourse-url>/users reason: Unexpected end of JSON input',
type: 'invalid-json' }
Which is strange seeing as I haven’t exactly changed the code one bit, obviously it was adapted to my Discourse, I have removed the URL because the site is not in production and I want to avoid crawlers finding it through this site.
I just validated the json being parsed and apparently it’s not valid either, this is kind of beyond me seeing as it worked yesterday
I have reworked the payload to include double quotations, but still I get invalid-json.