Notion to Medium Update Page Workflow 400 Error

Hi,

I’m writing articles in Notion. I want to transmit the articles from Notion to Medium.

Yesterday, I created my first workflow. When I click on Test Workflow the PipeDream site shows me this error:

Error

Request failed with status code 400

DETAILS

    at null.createError (/tmp/__pdg__/dist/code/f614438254758c8fa7d91453664046c0edf28e7106a96c10aa37493482c960b2/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/core/createError.js:16:15)
    at null.settle (/tmp/__pdg__/dist/code/f614438254758c8fa7d91453664046c0edf28e7106a96c10aa37493482c960b2/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/tmp/__pdg__/dist/code/f614438254758c8fa7d91453664046c0edf28e7106a96c10aa37493482c960b2/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/adapters/http.js:269:11)
    at IncomingMessage.emit (events.js:412:35)
    at null.endReadableNT (internal/streams/readable.js:1333:12)
    at process.processTicksAndRejections (internal/process/task_queues.js:82:21)

ExportsInputsLogsDetails

steps.medium_create_post{1}

Under Select Event I clicked try Now and I changed something in the Notion page.

PipeDream displays 1 New Event.

So it looks like PipeDream was able to detect my Notion page changed.

Ed

Hi @edswartz

First off, welcome to the Pipedream community. Happy to have you!

A 400 error means that the data you’re sending to an external API doesn’t match what that API is expecting.

Please refer to the API’s documentation and the error message in the response from the API for more details to narrow down which part of the payload is missing or is malformed.

You might be able to find more data in the Logs section of the step.

Hi,

There are no entries under Logs (Logs is greyed out).

Sorry, I’m totally lost given there is no details as to cause of the problem. Perhaps I didn’t fill out a field correctly?

Here’s a screenshot of the fields:

Through trial and error I found the source of my problem.

My workflow steps:

Step 1 looks for an updated Notion page.
Step 2 does “medium_create_post”.

I deleted step 2 and then recreated step 2.

I tested the workflow. It successfully created a new Medium story.

I overlooked setting PublishStatus and Tags. I set PublishStatus to Draft.

I successfully tested the workflow again.

I added a Tag “Quantum Computing”.

The test failed with the 400 error.

So, I removed the tag and was able to successfully run the workflow.

I assume “tags” maps to the topics one can select when publishing a story at Medium.

Looks like I’ll have to manually set the tags\topics in Medium itself.

Also:

However, when I look at the story on Medium all it shows is a link to my Notion page.

I guess that makes sense since I copied the Notion page’s web link into the medium_create_post workflow Content field.

How do I setup step 2 to display the actual Notion page data instead of the link?

Hi @edswartz

Glad to hear you were able to narrow down the cause of the 400 error.

I too needed to convert a Notion page into actual markdown, I went over my solution here:

I ended up finding an NPM module that would convert a Notion Page into Markdown in a Node.js code step on Pipedream.

Then you’ll be able to use that content in your Medium action.

Hi Pierce, thank you for the video.

I copied your code from the video and created a new action.

When I run the new step I get:

@notionhq/client warn: request fail { code: ‘invalid_request_url’, message: ‘Invalid request URL.’ }

Does Page ID refer to the Notion “web link” under the Share function?

I assume “invalid_request_url” refers to page_id which refers to Notion page web link.

How can I get the page_id from the previous step?

I guess I’d use the reference similar to the one I saw in your video for the call to PagetoMarkdown: steps.get_new_blog_post.$return.results[0].id. Correct?

But, the previous step needs to return the page_id. I’d have to look at that action code to make sure it returns the page id.

Also, I want to display messages at each steps of the action code using a print or alert type function, so I can see where the code is failing. How do I do that? I added print and alert and I get an error that those two functions are not defined.