Add PHP API
-
-
Thanks! But i have problems. I not understand how run curl command. Please, tell me how you would use them. Run in linux terminal:
curl -H "Authorization: Bearer {fb66eb42-8206-475e-fsdg-7ddabde551e5}" --data "title={Test post}&content=={Content test post}&cid={1}" http://localhost:4567/api/v1/topics
Output:
Forbidden
-
In top code hidden {2} in value cid. Markdown is hiding.
-
@julian said:
- No curly braces.
- Encode your post body data
curl -H "Authorization: Bearer fb66eb42-8206-475e-fsdg-7ddabde551e5" --data "title=Test%20post&content=Content%20test%20post&cid=1" http://localhost:4567/api/v1/topics
Forbidden
-
I tried user token and master token
-
-
NodeBB output:
2/3 19:20 [32175] - warn: Route requested but not found: /api/v1/topics 2/3 19:20 [32175] - error: /api/v1/topics Error: invalid csrf token at verifytoken (/home/me/www/forums/nodebb/node_modules/csurf/index.js:237:11) at Object.csrf [as applyCSRF] (/home/me/www/forums/nodebb/node_modules/csurf/index.js:100:7) at Object.middleware.buildHeader (/home/me/www/forums/nodebb/src/middleware/middleware.js:191:13) at /home/me/www/forums/nodebb/src/routes/index.js:200:15 at Layer.handle [as handle_request] (/home/me/www/forums/nodebb/node_modules/express/lib/router/layer.js:82:5) at trim_prefix (/home/me/www/forums/nodebb/node_modules/express/lib/router/index.js:302:13) at /home/me/www/forums/nodebb/node_modules/express/lib/router/index.js:270:7 at Function.proto.process_params (/home/me/www/forums/nodebb/node_modules/express/lib/router/index.js:321:12) at next (/home/me/www/forums/nodebb/node_modules/express/lib/router/index.js:261:10) at /home/me/www/forums/nodebb/src/routes/index.js:158:11
-
I got it...
-
I use not standart url - localhost:4567/forum
Url API replace to: localhost:4567/forum/api/v1/... -
curl -H "Authorization: Bearer fe9de6fb6-1234-44b7-8bbc-b5073fd1edef" --data "title=Тестовыйпост&content==роверкасодержимогопоста&cid=" http://localhost:4567/forum/api/v1/topics
Out:
{ "code": "not-authorised", "message": "You are not authorised to make this call", "params": {}
What is it?
-
@sergej-saveljev It looks like you're not passing in a
cid
...That error message seems like the token does not exist, or is not related to a proper uid...
-
-
Yes, everything is OK! Thanks!
Copyright © 2024 NodeBB | Contributors