Score:1

Uploading a user picture with json:api

ph flag

I'm trying to craft a curl request to upload an image to the user_picture field on a user entity using json:api.

The documentation is, umm, minimal, but I've used it as a starting point and I have this:

curl -s -X POST -b cookie.txt \
    --header "Accept: application/vnd.api+json" \
    --header "Content-type: application/octet-stream" \
    --header "X-CSRF-Token: $TOKEN" \
    --header "Content-Disposition: file: filename=test.jpg" \
    --data-binary "@test.jpg" \
    http://localhost/jsonapi/user/user/$UUID/user_picture

The response for this is "No route found that matches \"Content-Type: application/x-www-form-urlencoded\"".

What am I doing wrong?

Score:1
ph flag

As soon as I posted this I realised my issue, Content-type instead of Content-Type, duh!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.