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

**URL:** https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591
**Category:** General
**Created:** [December 9, 2021, 8:22am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591 "2021-12-09T08:22:44Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 9, 2021, 8:22am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/1 "2021-12-09T08:22:44Z")

</div>

Hi everybody,  
I have 2 forums [discourse1.com](http://discourse1.com), and [discourse2.com](http://discourse2.com),  
for example i have 3000 topics trên [discourse1.com](http://discourse1.com), I want to use API to convert 3000 topics in [discourse1.com](http://discourse1.com) to [discourse2.com](http://discourse2.com).

Can someone guide me with the code?  
thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 9, 2021, 8:39am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/2 "2021-12-09T08:39:12Z")

</div>

Maybe you want to know about [Topic and Category Export/Import](https://meta.discourse.org/t/topic-and-category-export-import/38930). The API isn’t a great way to do that.

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 9, 2021, 9:08am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/3 "2021-12-09T09:08:06Z")

</div>

Thanks @pfaffman ,

You can share more:

If there are 7000 topics in [discourse2.com](http://discourse2.com), then when I move 3000 topics from [discourse1.com](http://discourse1.com) to [discourse2.com](http://discourse2.com), the 7000 topics in [discourse2.com](http://discourse2.com) will not be deleted?  
Then [discourse2.com](http://discourse2.com) will have 7000+ 3000 topics = 10,000 topics?  
I’m worried, my 7000 topics at [discourse2.com](http://discourse2.com) will be deleted.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [December 9, 2021, 10:01am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/4 "2021-12-09T10:01:48Z")

</div>

> [@hokod](#):
>
> Then [discourse2.com](http://discourse2.com) will have 7000+ 3000 topics = 10,000 topics?

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.

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 9, 2021, 11:13am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/5 "2021-12-09T11:13:41Z")

</div>

Thanks ,  
i will try implementing ,

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 10, 2021, 5:36am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/6 "2021-12-10T05:36:04Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 10, 2021, 7:05am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/7 "2021-12-10T07:05:34Z")

</div>

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

> [@hokod](#):
>
> i tried switching, but the onebox of our topics then disappeared,

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.

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 10, 2021, 7:13am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/8 "2021-12-10T07:13:09Z")

</div>

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:

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/b/4b25862d77aafa53c26c03b2b7e053d8c88d4d20.png)

After:

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/7/17ae2c439f1225fa7fca5c272c7b0531a0403678.png)

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [December 10, 2021, 10:09am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/9 "2021-12-10T10:09:36Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 10, 2021, 10:30am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/10 "2021-12-10T10:30:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [December 10, 2021, 10:33am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/11 "2021-12-10T10:33:45Z")

</div>

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/d/ddd6b8dfcb394c18b9023cce296ac46f84a9cf33.png)

It will process the onebox again

---

<div class="post-metadata">

### Author: ![hokod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hokod/32/239410_2.png) [@hokod](https://meta.discourse.org/u/hokod)
#### Post date: [December 10, 2021, 10:37am UTC](https://meta.discourse.org/t/how-use-api-to-convert-topic-in-discourse1-com-to-discourse2-com/211591/12 "2021-12-10T10:37:02Z")

</div>

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.
