-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Steps to recreate
- Install with Cargo, or clone main and compile locally with cargo build.
- Export a key for a Dev.to account, an account that contains an article that was created on Dev.to Web version.
- Navigate to a directory that contains 4 articles, 3 that have previously been uploaded to Dev.to and 1 new article.
- Run
devtogo. - Expect Dev.to to return a
422error.
Dev.to error: 422 {"error":"article param must be a JSON object. You provided article as NilClass","status":422}Investigation
Have traced it to the POST operation and have removed the send and await from the POST request.
async move {
let resp = client
.post("https://dev.to/api/articles")
.header("api-key", api_key.as_str())
.json(&CreateArticleInput {
body_markdown: content,
});
println!("{:?}", resp);
Ok(())
}Which when printing returns the following without the article param.
RequestBuilder { method: POST, url: "https://dev.to/api/articles", headers: {"api-key": "API_KEY", "content-type": "application/json"} }It looks like the POST is being made with no value for the article which is why Dev.to throws a nilclass error which is what Ruby does when a value is nil or doesn't exist.
When printing the content that is to be converted by the reqwest json feature
let content2 = content.clone();
println!("{}", content2);It outputs the content without an issue.
---
title: Hello, World!
published: false
tags: discuss, help
series: Hello series
canonical_url: https://example.com/blog/hello
---
Hello DEV, this is my first postIdeas about what to try next
- Check whether
content.clone()is an issue - Check Reqwest and the json feature maybe they have issues?
Metadata
Metadata
Assignees
Labels
No labels