• Hi guys,

    so the thing is everything was working with the write api so far, topics,posts etc., but I can't insert/update a post to add tags into it. I'm trying to solve this problem all day because I thought it's an issue in my code at first but it seems that it's a bug.

    I've tried:

    • /topics POST inserting the cid,title,content,tags(and yes It's an array)(only the topic showed up with all the data except tags, with no error),

    • /topics PUT with pid,content and tags(again no error and no tags, the content was updated)

    • /posts PUT:pid with content,tags (again content was updated, still no tags,no errors)

    I'm on NodeBB version v1.1.2.

    Thanks in advance!

  • GNU/Linux Admin

    @Tilen-Štraus Confirmed working, can you please post your cURL statement to debug?

    Perhaps you can compare with mine 😄

    curl localhost:4567/api/v1/topics -H "Authorizatin: Bearer my-token" -X POST --data "title=test%20api%20topic&content=test%20content&cid=1&tags[]=one%20tag&tags[]=two%20tags"

  • Thank you for the quick answer @julian!
    I've tried your curl code and it works fine. The problem was that i've been using the wrong property('tags' instead of 'tags[]'). Now i'm getting a new problem when inserting an array [[email protected] Does he expect something else instead of the array? Here is my code for better understanding:

    var sub_cat_id = "146"
    var t_title = "test title"
    var t_content = "TESTESTESTESTEST";
    var cars = new Array("Saab", "Volvo", "BMW");

    var headers = {"Authorization" : "Bearer XXX"};
    var url = 'XX/api/v1/topics/';
    var data = {'cid' : sub_cat_id,
    'title' : t_title,
    'content' : t_content,
    'tags[]' : cars

    var options = {
    'method': 'post',
    'headers': headers,
    'payload': data
    var response = UrlFetchApp.fetch(url, options);

    I just tried almost everything 😃 JSON.stringify-gives only one tag with all of the values in the array. I srsly don't know what to do 😞 .

    Thank you again.

  • Look at this js example:
    var settings = {
    "async": true,
    "crossDomain": true,
    "url": "http://./api/v1/topics/18/tags",
    "method": "POST",
    "headers": {
    "authorization": "Bearer ",
    "cache-control": "no-cache",
    "content-type": "application/x-www-form-urlencoded"
    "data": {
    "tags[]": [

    $.ajax(settings).done(function (response) {

    2 things to consider:

    1. content-type
    2. tools to transform array to querystring - in my case jQuery will transform it to this - tags%5B%5D=closed&tags%5B%5D=test

  • Works now, i had to JSON.stringify()the data variable, set te contentType to "contentType" : "application/json" and 'tags[]' to 'tags'.

    Thank you all for helping 🙂

  • @Tilen-Štraus Glad you got it working, and thank you for sharing your solution for others who may run into the same trouble 😄

Suggested Topics

| | | |