How use API to convert topic in discourse1.com to discourse2.com

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

Can someone guide me with the code?
thanks!

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 discourse2.com, then when I move 3000 topics from discourse1.com to discourse2.com, the 7000 topics in discourse2.com will not be deleted?
Then discourse2.com will have 7000+ 3000 topics = 10,000 topics?
I’m worried, my 7000 topics at discourse2.com 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.

2 Likes

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.

Before:

After:

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

image

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.