Help needed: Posting to Bluesky with an attached image

I followed this guide made by @Donald_Mitchell and managed to get it working. However, I ran into an issue when trying to attach an image to the post.

First, I retrieve the file from a URL:

Next, I create a session as described in the guide:

Now, this is where I might be going wrong: I’m attempting to use the uploadBlob repo to convert the raw data into a blob.

The next step, creating a JSON, which looks like this:

The final step is just like in the guide:

With all of this, the post gets published, but the image isn’t attached, just the text. I’d really appreciate any help.

Thanks in advance (and sorry for my inexperience).

You’re missing the step where you upload the image to bluesky as a blob. You can’t use the url of the images original location. You have to upload it to bluesky as a blob, then use the blob ref link when creating your post.

This helped explain it really well: Manton Reece - Getting started with Bluesky XRPC

but I was having issues with the “image” code in the above example, so I used the image json code from the api: Creating a post | Bluesky

I’ll also note, I used Make’s ‘Image’ module to convert my images to jpeg first… not sure if that’s totally necessary, but I was having some issues uploading my image to bluesky until I did this.

1 Like

nope, that step is right here:

what was wrong is the JSON structure. i finally made it work yesterday using this structure:

{
  "repo": "BLUESKY_HANDLE",
  "record": {
    "text": "Just a test post via API",
    "createdAt": "2024-05-13T14:52:21.422Z",
    "embed": {
      "$type": "app.bsky.embed.images",
      "images": [
        {
          "alt": "brief alt text description of the first image",
          "image": {
            "$type": "blob",
            "ref": {
              "$link": "bafkreibabalobzn6cd366ukcsjycp4yymjymgfxcv6xczmlgpemzkz3cfa"
            },
            "mimeType": "image/webp",
            "size": 760898
          }
        },
        {
          "alt": "brief alt text description of the second image",
          "image": {
            "$type": "blob",
            "ref": {
              "$link": "bafkreif3fouono2i3fmm5moqypwskh3yjtp7snd5hfq5pr453oggygyrte"
            },
            "mimeType": "image/png",
            "size": 13208
          }
        }
      ]
    }
  },
  "collection": "app.bsky.feed.post"
}
2 Likes