How use API to convert topic in to

Hi everybody,
I have 2 forums, and,
for example i have 3000 topics trên, I want to use API to convert 3000 topics in to

Can someone guide me with the code?

1 Like

Maybe you want to know about Topic and Category Export/Import. The API isn’t a great way to do that.

1 Like

Thanks @pfaffman ,

You can share more:

If there are 7000 topics in, then when I move 3000 topics from to, the 7000 topics in will not be deleted?
Then will have 7000+ 3000 topics = 10,000 topics?
I’m worried, my 7000 topics at will be deleted.

This is ideally what should happen after a successful import.

It is advisable to backup both discourse 1 and discourse 2 before beginning the import/export just in case something breaks.


Thanks ,
i will try implementing ,

i tried switching, but the onebox of our topics then disappeared,

Is there another way to prevent onebox from being lost?
For example, how about using the API?

If you want to copy topics from one forum to another the script I suggested is the way to do it.

I don’t know what this means. Switching what?

Are you saying that you used that script and when it imported the topics the resulting topics are missing one boxes? Do they come back if you go to the wrench and rebuild html? If so you can either rebake the posts from the command line, or, I suspect, just wait.

My result is the same as in the image, the onebox in the topics is missing.
So I thought of using API, but I’m not sure either: the API method will maintain onebox.



Thats normal, you need to do a rebake, the posts will be processed and the oneboxes wilo be generated:

cd /var/discourse
./launcher enter app
rake posts:rebake

thanks @Steven ,

I still expect to be able to use the API,
because rake posts:rebake will lead to our other topics also rebake.
For certain reasons, it is very difficult for us to make a rebake decision.

You can rebuild each post manually using the then the wrench icon to open a few option, use Rebuild HTML


It will process the onebox again

1 Like

really thank you,
however, we have many topics, if we do it manually it will not be enough time and cost.

Hope someone, can guide me to use the API, without removing onebox.