How do you save the response object into a variable?

From this documentation : Projects API | GitLab
I want to save this response into a variable :

{
  "alt": "dk",
  "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "full_path": "/namespace1/project1/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
  "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
}

I tried 2 things but didn’t work for me :
1.

json=$(curl --request POST --header “PRIVATE-TOKEN:” --header “Content-Type:multipart/form-data” --form “file=@./ticket.json” “https://gitlab.com/api/v4/projects/uploads”)

json=`curl --request POST --header “PRIVATE-TOKEN:” --header “Content-Type:multipart/form-data” --form “file=@./ticket.json” “https://gitlab.com/api/v4/projects/uploads” ``

both these methods doesn’t work for me .

Where is your project id in the URL? The API endpoint is https://gitlab.com/api/v4/projects/PROJECT_ID/uploads

Sorry to post incomplete url , But in the script project Id was there , I manage to make it work by Saving the output in to a file

  • curl --request POST --header “PRIVATE-TOKEN:${VERSION_UPDATE_TOKEN}” --header “Content-Type:multipart/form-data” --form “file=@./ticket.json” “${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/uploads” >> path.json