API posts don't onebox


(Jeron Paraiso) #1

I’m trying to make a post via the API which contains an “a” tag, pointing to a .oembed endpoint. Discourse doesn’t seem to replace the link with the right content though, until I click the little pencil button, and I see the content preview.

Is there any way to make it happen via the api?


(cpradio) #2

Can you post a sample of the RAW content you are sending in the API? As my use of the API oneboxes links just fine…


(Jeron Paraiso) #3

Hmm, okay here’s the sample:
{base_url}/program_profiles/{subject.profile.id}

It’s just text that ends up in my local environments as http://localhost:3000/program_profiles/929393910

Again, not sure if this is helpful, but the moment I click the edit button and see the wysiwyg + preview, the onebox content appears in the preview:

EDIT pt2:
Here is the raw output from my discourse server logs:

I, [2016-05-12T10:57:46.377298 #84800] INFO – : Started POST “/posts?api_key=(key)&api_username=jeron” for 127.0.0.1 at 2016-05-12 10:57:46 -0700
I, [2016-05-12T10:57:46.493462 #84800] INFO – : Processing by PostsController#create as JSON
I, [2016-05-12T10:57:46.495174 #84800] INFO – : Parameters: {“auto_track”=>“true”, “category”=>“Published Stuff”, “raw”=>“http://localhost:3000/program_profiles/771199379”, “skip_validations”=>“true”, “title”=>“AnotherThingThen”, “api_key”=>"(key)", “api_username”=>“jeron”}


(Mittineague) #4

Are you sure you’re using the correct port number?

For example, my localhost is Windows 10, VirtualBox, GitHub, Vagrant.

Because of the way the VM works, I need to go to http://localhost:4000 in my browser.

Until I changed the default Admin setting to use port 4000 instead of 3000 I had similar problems with images in posts.