tumblr / docs

Tumblr's public platform documentation.
Apache License 2.0
108 stars 26 forks source link

/blog/{blog-identifier}/posts sending a undocumented code "0" with HTTP 400 #129

Closed net-tech closed 5 months ago

net-tech commented 5 months ago

Hi there. I've hit a bump while using the Tumblr API with Tumblr.js. When I tried to create a new post using the endpoint blog/{blog-identifier}/posts, I got an error with code 0. Here's the data:

Request:


POST /v2/blog/nettech-testing-blog.tumblr.com/posts HTTP/1.1
Host: api.tumblr.com
User-Agent: tumblr.js/5.0.0
Accept: application/json
Authorization: <redact>
Content-Type: application/json
Content-Length: 676
Connection: close

{
"source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475",
"date": "Mon Mar 18 13:00:56 +0000 2024",
"tags": "#nintendo,#splatoon,#splatoon3,#splatoon 3",
"content": [
    {
    "type": "text",
    "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\""
    },
    {
    "type": "image",
    "media": {
        "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16"
    },
    "attribution": {
            "type": "link",
            "url": "https://nintendo.com/"
            }
        }
    ]
}

And here's what Tumblr gave me back:

Response:

HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 15 Apr 2024 16:39:17 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 141
Connection: close
X-Rid: 13e39db0c7173514b62d30f2a9096595
P3p: CP="Tumblr's privacy policy is available here: https://www.tumblr.com/policy/en/privacy"
X-Ratelimit-Perday-Limit: 5000
X-Ratelimit-Perday-Remaining: 4999
X-Ratelimit-Perday-Reset: 86400
X-Ratelimit-Perhour-Limit: 1000
X-Ratelimit-Perhour-Remaining: 999
X-Ratelimit-Perhour-Reset: 3600
Strict-Transport-Security: max-age=31536000; preload
Alt-Svc: h3=":443"; ma=86400

{
"meta": {
"status": 400,
"msg": "Bad Request"
},
"response": [],
"errors": [
        {
            "title": "Bad Request",
            "code": 0,
            "detail": "Tumblr went thud. Try again."
        }
    ]
}

The error message just says "Tumblr went thud. Try again," with a generic 400 which isn't super helpful. I've combed through the API docs but didn't find any info on error code 0 or how to fix it.

Can anyone some light on what might be causing this? Any tips on troubleshooting or extra details I should include in my request would be awesome. X-Rid is also in the response object which I suspect is the ID of the request.

Environment Info:

macOS Version: 14.4.1
Chip: Apple M2 Pro
Architecture: arm64

JavaScript/TypeScript Project Information:
Node.js Version: v20.4.0
TypeScript Version: Version 5.4.3
tumblr.js Version: 5.0.0
nightpool commented 5 months ago

I think the tags should be a comma separated string without # included, unfortunately tumblrs error messages aren't always the most helpful.

On Sun, Apr 21, 2024, 6:11 AM nettech @.***> wrote:

Hi there. I've hit a bump while using the Tumblr API with Tumblr.js. When I tried to create a new post using the endpoint blog/{blog-identifier}/posts, I got an error with code 0. Here's the data: Request:

POST /v2/blog/nettech-testing-blog.tumblr.com/posts HTTP/1.1 Host: api.tumblr.com User-Agent: tumblr.js/5.0.0 Accept: application/json Authorization: Content-Type: application/json Content-Length: 676 Connection: close

{ "source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475", "date": "Mon Mar 18 13:00:56 +0000 2024", "tags": "#nintendo,#splatoon,#splatoon3,#splatoon 3", "content": [ { "type": "text", "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\"" }, { "type": "image", "media": { "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16" }, "attribution": { "type": "link", "url": "https://nintendo.com/" } } ] }

And here's what Tumblr gave me back: Response:

HTTP/1.1 400 Bad Request Server: nginx Date: Mon, 15 Apr 2024 16:39:17 GMT Content-Type: application/json; charset=utf-8 Content-Length: 141 Connection: close X-Rid: 13e39db0c7173514b62d30f2a9096595 P3p: CP="Tumblr's privacy policy is available here: https://www.tumblr.com/policy/en/privacy" X-Ratelimit-Perday-Limit: 5000 X-Ratelimit-Perday-Remaining: 4999 X-Ratelimit-Perday-Reset: 86400 X-Ratelimit-Perhour-Limit: 1000 X-Ratelimit-Perhour-Remaining: 999 X-Ratelimit-Perhour-Reset: 3600 Strict-Transport-Security: max-age=31536000; preload Alt-Svc: h3=":443"; ma=86400

{ "meta": { "status": 400, "msg": "Bad Request" }, "response": [], "errors": [ { "title": "Bad Request", "code": 0, "detail": "Tumblr went thud. Try again." } ] }

The error message just says "Tumblr went thud. Try again," with a generic 400 which isn't super helpful. I've combed through the API docs but didn't find any info on error code 0 or how to fix it.

Can anyone some light on what might be causing this? Any tips on troubleshooting or extra details I should include in my request would be awesome. X-Rid is also in the response object which I suspect is the ID of the request. Environment Info:

macOS Version: 14.4.1 Chip: Apple M2 Pro Architecture: arm64

JavaScript/TypeScript Project Information: Node.js Version: v20.4.0 TypeScript Version: Version 5.4.3 tumblr.js Version: 5.0.0

— Reply to this email directly, view it on GitHub https://github.com/tumblr/docs/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZCVZOJKSGVQXVZCE4M7LY6ONFVAVCNFSM6AAAAABGRJHZZCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TKMBSGIYTMOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

nightpool commented 5 months ago

the date format also doesn't look right to me, it should be strict ISO 8601 format, like 2024-03-18T13:00:00Z

On Sun, Apr 21, 2024, 1:15 PM nightpool @.***> wrote:

I think the tags should be an array of strings without # included, unfortunately tumblrs error messages aren't always the most helpful.

On Sun, Apr 21, 2024, 6:11 AM nettech @.***> wrote:

Hi there. I've hit a bump while using the Tumblr API with Tumblr.js. When I tried to create a new post using the endpoint blog/{blog-identifier}/posts, I got an error with code 0. Here's the data: Request:

POST /v2/blog/nettech-testing-blog.tumblr.com/posts HTTP/1.1 Host: api.tumblr.com User-Agent: tumblr.js/5.0.0 Accept: application/json Authorization: Content-Type: application/json Content-Length: 676 Connection: close

{ "source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475", "date": "Mon Mar 18 13:00:56 +0000 2024", "tags": "#nintendo,#splatoon,#splatoon3,#splatoon 3", "content": [ { "type": "text", "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\"" }, { "type": "image", "media": { "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16" }, "attribution": { "type": "link", "url": "https://nintendo.com/" } } ] }

And here's what Tumblr gave me back: Response:

HTTP/1.1 400 Bad Request Server: nginx Date: Mon, 15 Apr 2024 16:39:17 GMT Content-Type: application/json; charset=utf-8 Content-Length: 141 Connection: close X-Rid: 13e39db0c7173514b62d30f2a9096595 P3p: CP="Tumblr's privacy policy is available here: https://www.tumblr.com/policy/en/privacy" X-Ratelimit-Perday-Limit: 5000 X-Ratelimit-Perday-Remaining: 4999 X-Ratelimit-Perday-Reset: 86400 X-Ratelimit-Perhour-Limit: 1000 X-Ratelimit-Perhour-Remaining: 999 X-Ratelimit-Perhour-Reset: 3600 Strict-Transport-Security: max-age=31536000; preload Alt-Svc: h3=":443"; ma=86400

{ "meta": { "status": 400, "msg": "Bad Request" }, "response": [], "errors": [ { "title": "Bad Request", "code": 0, "detail": "Tumblr went thud. Try again." } ] }

The error message just says "Tumblr went thud. Try again," with a generic 400 which isn't super helpful. I've combed through the API docs but didn't find any info on error code 0 or how to fix it.

Can anyone some light on what might be causing this? Any tips on troubleshooting or extra details I should include in my request would be awesome. X-Rid is also in the response object which I suspect is the ID of the request. Environment Info:

macOS Version: 14.4.1 Chip: Apple M2 Pro Architecture: arm64

JavaScript/TypeScript Project Information: Node.js Version: v20.4.0 TypeScript Version: Version 5.4.3 tumblr.js Version: 5.0.0

— Reply to this email directly, view it on GitHub https://github.com/tumblr/docs/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZCVZOJKSGVQXVZCE4M7LY6ONFVAVCNFSM6AAAAABGRJHZZCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TKMBSGIYTMOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

net-tech commented 5 months ago

Hi,

I fixed the errors you mentioned and now the error message has changed from "Tumblr went thud. Try again" to "Something goofed. Try again." but still with the same Tumblr and HTTP status codes.

Request

POST /v2/blog/nettech-testing-blog.tumblr.com/posts HTTP/1.1
Host: api.tumblr.com
User-Agent: tumblr.js/5.0.0
Accept: application/json
Authorization: <redact>
Content-Type: application/json
Content-Length: 666
Connection: close

{
  "source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475",
  "date": "2024-03-18T13:00:56.000Z",
  "tags": "nintendo,splatoon,splatoon3,splatoon 3",
  "content": [
    {
      "type": "text",
      "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\""
    },
    {
      "type": "image",
      "media": {
        "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16"
      },
      "attribution": {
        "type": "link",
        "url": "https://nintendo.com/"
      }
    }
  ]
}

Response

POST /v2/blog/nettech-testing-blog.tumblr.com/posts HTTP/1.1
Host: api.tumblr.com
User-Agent: tumblr.js/5.0.0
Accept: application/json
Authorization: <redact>
Content-Type: application/json
Content-Length: 666
Connection: close

{
  "source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475",
  "date": "2024-03-18T13:00:56.000Z",
  "tags": "nintendo,splatoon,splatoon3,splatoon 3",
  "content": [
    {
      "type": "text",
      "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\""
    },
    {
      "type": "image",
      "media": {
        "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16"
      },
      "attribution": {
        "type": "link",
        "url": "https://nintendo.com/"
      }
    }
  ]
}
marcustyphoon commented 5 months ago

You're trying to use a video as the source for an image block!

Here's a working content JSON example that posts an image with a link to the video in question:

{
  "source_url": "https://twitter.com/SplatoonNA/status/1769710579730526475",
  "date": "2024-03-18T13:00:56.000Z",
  "tags": "nintendo,splatoon,splatoon3,splatoon 3",
  "content": [
    {
      "type": "text",
      "text": "During the Splatfest, Off the Hook will perform an updated version of Color Pulse for their Splatsville fans! Sez Marina, \"Singing that intro always reminds me of seven years ago when we first took the stage with the legendary Squid Sisters. Feels like it was yesterday!\""
    },
    {
      "type": "image",
      "media": {
        "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/SpaceX_CRS-22_Squid_Experiment_%28KSC-20210520-PH-ILW01_0111%29.jpg/640px-SpaceX_CRS-22_Squid_Experiment_%28KSC-20210520-PH-ILW01_0111%29.jpg"
      },
      "attribution": {
        "type": "link",
        "url": "https://video.twimg.com/amplify_video/1769710369059069952/vid/avc1/1920x1080/8LhOs8LKiH-Ghvhe.mp4?tag=16"
      }
    }
  ]
}

(And yeah, just ignore the "detail" error field, that's just used to show error messages to the user. They're all just 400 bad request errors. Try removing all but the necessary fields to get your post to post, then add them back one at a time to find which are malformed.)

marcustyphoon commented 5 months ago

(Additional note that the date and tags fields of your original post do seem to work fine, once the invalid image block is removed.)

net-tech commented 5 months ago

I'm really not sure how I didn't notice that 😅. Sorry for wasting your time and thank you @nightpool and @marcustyphoon