Upload a container to registry V2 using API (2.5.1) - api
Hi, I'm trying to upload a docker container to a private docker registry using the API.
Using docker command everything seems to works just fine:
docker pull ubuntu:16.04
docker tag ubuntu:16.04 <PRIVATE-REGISTRY-IP>:5000/ubuntu/16.04
docker push <PRIVATE-REGISTRY-IP>:5000/ubuntu/16.04
I'm trying to upload the same image using the API, what I've done:
export the container using docker save ubuntu:16.04 -o ubuntu.tar
untar the container file tar xf ubuntu.tar
upload all the layers with curl
upload manifest with curl
Ok, reading the doc, the layers must be PUT separatedly each one with their digest obtained using sha256sum <LAYER-FILE> and after it's done, manifest should be also PUT onto registry
curl call details :)
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["318d5752-b10b-49da-9ebf-5891b679a805"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:53 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/318d5752-b10b-49da-9ebf-5891b679a805?_state\u003dv2nk-ATsPGQKJatyjUQTSJwl2BlQywrqeCkVTzQj0uh7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiMzE4ZDU3NTItYjEwYi00OWRhLTllYmYtNTg5MWI2NzlhODA1IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjE1Njk5NzUxM1oifQ%3D%3D"]}
DIGEST=$(sha256sum /home/user/container/ubuntu/3e1722599d1d5331b610200b6b41f895759e312ff1f14e009bee2f52f962b69f/layer.tar)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/3e1722599d1d5331b610200b6b41f895759e312ff1f14e009bee2f52f962b69f/layer.tar http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/318d5752-b10b-49da-9ebf-5891b679a805?_state=v2nk-ATsPGQKJatyjUQTSJwl2BlQywrqeCkVTzQj0uh7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiMzE4ZDU3NTItYjEwYi00OWRhLTllYmYtNTg5MWI2NzlhODA1IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjE1Njk5NzUxM1oifQ%3D%3D&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:53 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:bf6751561805be7d07d66f6acb2a33e99cf0cc0a20f5fd5d94a3c7f8ae55c2a1"],"Docker-Content-Digest":["sha256:bf6751561805be7d07d66f6acb2a33e99cf0cc0a20f5fd5d94a3c7f8ae55c2a1"]}
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["7680a9d6-7686-49a6-a6fa-44979370c2ec"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:53 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/7680a9d6-7686-49a6-a6fa-44979370c2ec?_state\u003duyI8QOIktlkc_9qynIKOXJC0FaVT6YQPlpRGfwNXHgV7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiNzY4MGE5ZDYtNzY4Ni00OWE2LWE2ZmEtNDQ5NzkzNzBjMmVjIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjU3NDc3ODk3OVoifQ%3D%3D"]}
code: $1
body:$2
DIGEST=$(sha256sum /home/user/container/ubuntu/6f12534822c57808e10e079842da48607c40eeb82048541320ba454af83cf021/layer.tar)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/6f12534822c57808e10e079842da48607c40eeb82048541320ba454af83cf021/layer.tar http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/7680a9d6-7686-49a6-a6fa-44979370c2ec?_state=uyI8QOIktlkc_9qynIKOXJC0FaVT6YQPlpRGfwNXHgV7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiNzY4MGE5ZDYtNzY4Ni00OWE2LWE2ZmEtNDQ5NzkzNzBjMmVjIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjU3NDc3ODk3OVoifQ%3D%3D&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:53 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:943edb549a8300092a714190dfe633341c0ffb483784c4fdfe884b9019f6a0b4"],"Docker-Content-Digest":["sha256:943edb549a8300092a714190dfe633341c0ffb483784c4fdfe884b9019f6a0b4"]}
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["8b7245b4-9f42-42e6-8512-6b645ac233a0"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:54 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/8b7245b4-9f42-42e6-8512-6b645ac233a0?_state\u003dg5hAehwCOPnnMhfUC-Ugu_-lX9pp5NgJdTjB7cp0hO57Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiOGI3MjQ1YjQtOWY0Mi00MmU2LTg1MTItNmI2NDVhYzIzM2EwIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjk4NDA1OTE4N1oifQ%3D%3D"]}
code: $1
body:$2
DIGEST=$(sha256sum /home/user/container/ubuntu/23a78ada034808b66348c42b9bb941901651b533b445cfb94e6b7646d2e2110d/layer.tar)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/23a78ada034808b66348c42b9bb941901651b533b445cfb94e6b7646d2e2110d/layer.tar http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/8b7245b4-9f42-42e6-8512-6b645ac233a0?_state=g5hAehwCOPnnMhfUC-Ugu_-lX9pp5NgJdTjB7cp0hO57Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiOGI3MjQ1YjQtOWY0Mi00MmU2LTg1MTItNmI2NDVhYzIzM2EwIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjUzLjk4NDA1OTE4N1oifQ%3D%3D&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:54 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:c1bd37d01c89de343d68867518b1155cb297d8e03942066ecb44ae8f46b608a3"],"Docker-Content-Digest":["sha256:c1bd37d01c89de343d68867518b1155cb297d8e03942066ecb44ae8f46b608a3"]}
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["8d97ab31-5801-4bdd-bdfd-a4878b9e7317"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:05:55 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/8d97ab31-5801-4bdd-bdfd-a4878b9e7317?_state\u003d0NkM--lD5vDA_wlPiPd1dEs-7WwDSmb_UfGJmMDAsIR7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiOGQ5N2FiMzEtNTgwMS00YmRkLWJkZmQtYTQ4NzhiOWU3MzE3IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjU1LjE5MDY1NDkzWiJ9"]}
code: $1
body:$2
DIGEST=$(sha256sum /home/user/container/ubuntu/a940c634b64a460f47e4c5d6f51e49c28280eb9e0e3da24df76b00c8c60ba756/layer.tar)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/a940c634b64a460f47e4c5d6f51e49c28280eb9e0e3da24df76b00c8c60ba756/layer.tar http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/8d97ab31-5801-4bdd-bdfd-a4878b9e7317?_state=0NkM--lD5vDA_wlPiPd1dEs-7WwDSmb_UfGJmMDAsIR7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiOGQ5N2FiMzEtNTgwMS00YmRkLWJkZmQtYTQ4NzhiOWU3MzE3IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA1OjU1LjE5MDY1NDkzWiJ9&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:06:07 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:e7ebc6e16708285bee3917ae12bf8d172ee0d7684a7830751ab9a1c070e7a125"],"Docker-Content-Digest":["sha256:e7ebc6e16708285bee3917ae12bf8d172ee0d7684a7830751ab9a1c070e7a125"]}
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["bb5ccb7c-4bf2-4a80-a78f-36cd01d139a5"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:06:08 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/bb5ccb7c-4bf2-4a80-a78f-36cd01d139a5?_state\u003dLyO6bZxCT0B1bfJXxnwVnsRmshIZgDvAr9VdREmmOEB7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiYmI1Y2NiN2MtNGJmMi00YTgwLWE3OGYtMzZjZDAxZDEzOWE1IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA2OjA3Ljk5NDA4MjYzNFoifQ%3D%3D"]}
code: $1
body:$2
DIGEST=$(sha256sum /home/user/container/ubuntu/b7f0f1a6360ea96cc4ec0a3a28aaf8a385807ed42ceb372cd46d08d12711ad45/layer.tar)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/b7f0f1a6360ea96cc4ec0a3a28aaf8a385807ed42ceb372cd46d08d12711ad45/layer.tar http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/bb5ccb7c-4bf2-4a80-a78f-36cd01d139a5?_state=LyO6bZxCT0B1bfJXxnwVnsRmshIZgDvAr9VdREmmOEB7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiYmI1Y2NiN2MtNGJmMi00YTgwLWE3OGYtMzZjZDAxZDEzOWE1IiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA2OjA3Ljk5NDA4MjYzNFoifQ%3D%3D&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:06:08 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:f934e33a54a60630267df295a5c232ceb15b2938ebb0476364192b1537449093"],"Docker-Content-Digest":["sha256:f934e33a54a60630267df295a5c232ceb15b2938ebb0476364192b1537449093"]}
curl -XPOST -H 'accept: application/json' http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/
response headers: {"Docker-Distribution-Api-Version":["registry/2.0"],"Docker-Upload-Uuid":["55b5d57c-4169-4884-8068-cf3a79fc8cef"],"X-Content-Type-Options":["nosniff"],"Range":["0-0"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:06:08 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/55b5d57c-4169-4884-8068-cf3a79fc8cef?_state\u003dy3gKd9CDD-Auw_mast0ki4dzXrO1vsnUOvv7eqZIgRl7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiNTViNWQ1N2MtNDE2OS00ODg0LTgwNjgtY2YzYTc5ZmM4Y2VmIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA2OjA4LjQwNDQ5ODcwM1oifQ%3D%3D"]}
code: $1
body:$2
DIGEST=$(sha256sum /home/user/container/ubuntu/e4415b714b624040f19f45994b51daed5cbdb00e0eb9a07221ff0bd6bcf55ed7.json)
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/e4415b714b624040f19f45994b51daed5cbdb00e0eb9a07221ff0bd6bcf55ed7.json http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/55b5d57c-4169-4884-8068-cf3a79fc8cef?_state=y3gKd9CDD-Auw_mast0ki4dzXrO1vsnUOvv7eqZIgRl7Ik5hbWUiOiJ0ZXN0MDEiLCJVVUlEIjoiNTViNWQ1N2MtNDE2OS00ODg0LTgwNjgtY2YzYTc5ZmM4Y2VmIiwiT2Zmc2V0IjowLCJTdGFydGVkQXQiOiIyMDE2LTExLTIzVDE2OjA2OjA4LjQwNDQ5ODcwM1oifQ%3D%3D&digest=sha256:${DIGEST}
code: 201
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["0"],"Date":["Wed, 23 Nov 2016 16:06:08 GMT"],"Content-Type":["text/plain; charset\u003dutf-8"],"Location":["http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/sha256:e4415b714b624040f19f45994b51daed5cbdb00e0eb9a07221ff0bd6bcf55ed7"],"Docker-Content-Digest":["sha256:e4415b714b624040f19f45994b51daed5cbdb00e0eb9a07221ff0bd6bcf55ed7"]}
curl -XPUT -H 'accept: application/json' -d #/home/user/container/ubuntu/manifest.json http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/manifests/16.04
code: 400
body: {"Docker-Distribution-Api-Version":["registry/2.0"],"X-Content-Type-Options":["nosniff"],"Content-Length":["118"],"Date":["Wed, 23 Nov 2016 16:06:08 GMT"],"Content-Type":["application/json; charset\u003dutf-8"]}
{"errors":[{"code":"MANIFEST_INVALID","message":"manifest invalid","detail":{"Value":"array","Type":{},"Offset":1}}]}
I've also tried to generate a manual manifest with the minimal content but also get error from the manifest PUT:
{
"schemaVersion": 2,
"name": "ubuntu",
"tag": "16.04",
"fsLayers": [
{"blobSum": "sha256:bf6751561805be7d07d66f6acb2a33e99cf0cc0a20f5fd5d94a3c7f8ae55c2a1"},
{"blobSum": "sha256:943edb549a8300092a714190dfe633341c0ffb483784c4fdfe884b9019f6a0b4"},
{"blobSum": "sha256:c1bd37d01c89de343d68867518b1155cb297d8e03942066ecb44ae8f46b608a3"},
{"blobSum": "sha256:e7ebc6e16708285bee3917ae12bf8d172ee0d7684a7830751ab9a1c070e7a125"},
{"blobSum": "sha256:f934e33a54a60630267df295a5c232ceb15b2938ebb0476364192b1537449093"}
]
}
Other details:
docker registry version :
registry github.com/docker/distribution v2.5.1
docker version:
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.6.2
Git commit: 23cf638
Built: Tue, 27 Sep 2016 12:25:38 +1300
OS/Arch: linux/amd64
Server:
Version: 1.12.1
API version: 1.24
Go version: go1.6.2
Git commit: 23cf638
Built: Tue, 27 Sep 2016 12:25:38 +1300
OS/Arch: linux/amd64
I found only one article really describing this, which works.
https://www.danlorenc.com/post/containers-part-2/
The article describes to create and upload one layer with V1 config and Manifest to google registry, but it's a good base to learn the concept.
I'll put the concept down in case the website disappears, all credit to the author github.com/dlorenc of that article.
Basicly before creating your manifest, you need to create a v1+json config, and upload it as a blob, where the V1+json config contains the layers with the digest of the content, not the blob.
cat <<EOF > config.json
{
"architecture": "amd64",
"config": {
},
"history": [
{
"created_by": "Bash!"
}
],
"os": "linux",
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:$(gunzip layer.tar.gz --to-stdout | shasum -a 256 | cut -d' ' -f1)"
]
}
}
EOF
With the config and layer in place, you can define the manifest:
# We need to know the size and digest of our layer and config:
size=$(wc -c layer.tar.gz | awk '{print $1}')
digest="sha256:$(shasum -a 256 layer.tar.gz | cut -d' ' -f1)"
config_size=$(wc -c config.json | awk '{print $1}')
config_digest="sha256:$(shasum -a 256 config.json | cut -d' ' -f1)"
cat << EOF > manifest.json
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": $config_size,
"digest": "$config_digest"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": $size,
"digest": "$digest"
}
]
}
EOF
Now you can upload your layers:
# Check to see if the layer exists:
returncode=$(curl -w "%{http_code}" \
-o /dev/null \
-I http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/$digest)
if [[ $returncode -ne 200 ]]; then
# Start the upload and get the location header.
# The HTTP response seems to include carriage returns, which we need to strip
location=$(curl -i -X POST \
http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/ \
-d "" | grep Location | cut -d" " -f2 | tr -d '\r')
# Do the upload
curl -X PUT $location\?digest=$digest --data-binary #layer.tar.gz
fi
Upload Config, basicly same code as for the layer:
returncode=$(curl -w "%{http_code}" -o /dev/null \
-I http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/$config_digest)
if [[ $returncode -ne 200 ]]; then
# Start the upload and get the location header.
# The HTTP response seems to include carriage returns, which we need to strip
location=$(curl -i -X POST \
http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/blobs/uploads/ \
-d "" | grep Location | cut -d" " -f2 | tr -d '\r')
# Do the upload
curl -X PUT $location\?digest=$config_digest --data-binary #config.json
fi
and TAG your image by pushing the manifest:
curl -X PUT \
http://<PRIVATE-REGISTRY-IP>:5000/v2/ubuntu/manifests/16.04 --data-binary #manifest.json
Remark
example code does not do the authorisation.
Does not work on the openshift online starter internal-registry (400 invalid manifest)
need manual redirect on gitlab-registry as it returns 400 with a location header for blobs HEAD and GET
Related
Propagate a return to the WMS with Shippingbo
My company uses Shippingbo as an OMS and WMS I try to create a return order from the OMS to the WMS The return order is rightly created in my OMS but not in my WMS and I have to trigger the propagation in the UI and I would like to do it automaticaly The request I made: curl --request POST \ --url https://app.shippingbo.com/returns_orders \ --header 'X-API-USER: my_user' \ --header 'X-API-TOKEN: passwd' \ --header 'X-API-VERSION: 1' \ --header 'Content-Type: application/json' \ --data '{ "source": "Prestashop-staging", "source_ref": "XMLPJGHU", "reason": "Bad size", "reason_ref": "S/M", "return_order_type": "return_order_customer", "return_order_expected_items_attributes": [ { "quantity": 1, "user_ref": "shirt-and-flag" } ] }'
You must add an additional parameter that is the supplier_id curl --request POST \ --url https://app.shippingbo.com/returns_orders \ --header 'X-API-USER: my_user' \ --header 'X-API-TOKEN: passwd' \ --header 'X-API-VERSION: 1' \ --header 'Content-Type: application/json' \ --data '{ "source": "Prestashop-staging", "source_ref": "XMLPJGHU", "reason": "Bad size", "reason_ref": "S/M", "return_order_type": "return_order_customer", "supplier_id": __your_id__, "return_order_expected_items_attributes": [ { "quantity": 1, "user_ref": "shirt-and-flag" } ] }' To get the supplier_id you can request: curl --request GET \ --url https://app.shippingbo.com/suppliers/available_for_return_order \ --header 'Content-Type: application/json' Don't forget to add your credentials in the header
active docker realms in nexus3 api
How can i active DockerToken realms in nexus 3.38? I use this URL but not work and docker realms is not activated. curl -XPUT -H "accept: application/json" -u admin:pass -d '{"id" : "DockerToken"}' http://192.168.254.10:8081/service/rest/v1/security/realms/active Or reamls.json [ "id": "DockerToken" ] curl -XPUT -H "Content-Type: text/plain" -u admin:pass -d #realms.json http://192.168.254.10:8081/service/rest/v1/security/realms/
I think should help this request: curl -XPUT -H "Content-Type: application/json" -u admin:pass --data-raw '["NexusAuthenticatingRealm", "NexusAuthorizingRealm", "DockerToken"]' http://192.168.254.10:8081/service/rest/v1/security/realms/active
add role to a user in a client keycloak
i want to add role to user in specific client keycloak by api in postman but i get "error": "Client not found" this url: POST- http://localhost:8080/auth/admin/realms/{realmName}/users/{userId}/role-mappings/clients/{clientId} this Body: { "roles": [ { "id": "0830ff39-43ea-48bb-af8f-696bc420c1ce", "name": "confirm-kilid-user", "description": "${role_uma_authorization}", "composite": false, "clientRole": true, "containerId": "344e7c81-e7a2-4a43-b013-57d7ed198eee" } ] }
This curl works. We should give clientId ("a48108f0-8465-4f91-8a90-39c72f1a05b8") as containerId and roleId ("36c11a6e-a43a-427c-9c28-90352b369d79") as Id. curl -X POST \ http://localhost:7600/auth/admin/realms/adanic/users/4cf43901-663a-4796-bca7-fdfb8642476d/role-mappings/clients/a48108f0-8465-4f91-8a90-39c72f1a05b8 \ -H 'Accept: */*' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJtNnlDZ1ZsbVZRbW5QSmo2UC14Vm1rdG84dnVKNVdhSnlqNTR6d1llSHk0In0.eyJqdGkiOiJjY2U3YTVjNy03YTRmLTQ2ODktYTM2Zi03YjkyOTJhNjlkY2EiLCJleHAiOjE1Nzc1OTg4NDgsIm5iZiI6MCwiaWF0IjoxNTc3NTEyNDQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0Ojc2MDAvYXV0aC9yZWFsbXMvbWFzdGVyIiwic3ViIjoiYzJmOGQwYTctZDYyOC00OWEwLWFhZTUtNzdiMDBkMzRkNjQ4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiYWRtaW4tY2xpIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiN2Q4OThhZjAtN2FkMS00YzVkLTgwNmQtOWQwMTNlNDEwMjY0IiwiYWNyIjoiMSIsInNjb3BlIjoicHJvZmlsZSBlbWFpbCBwaG9uZSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4ifQ.IZ9mx-05mNU2UOvKDXjLbiSbbpoVV7sTKeXAzY7bLbduYApDA9vRsOkUCLB_2Hhdj53Fjp_DxoMKkRsc-D4GIbTTBpKEmB65cH8xsKlt-Ne9vMLW5n_SZRaptTysUHPSfh-NxlUSFwAjXyYp2cH1TQBmUVW3czF1b_8i8b3KAIheq7VLyZcQ8mUTTli1egHlUNLOoqmQO3BEU-fcaI4SPfMHZ4pDWYfFHUJ3B1-be1MTCaVT3LVZKpi7spb-H_o3zmRJnLQdxDqG0-BAIBsytaq6vQ1gf4wzQAzbTvT5VB8FnyRkWID8vum4MW_3XfjABPS2_j1F2cs7Grh7xYd2ew' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Content-Length: 285' \ -H 'Content-Type: application/json' \ -H 'Host: localhost:7600' \ -H 'User-Agent: PostmanRuntime/7.20.1' \ -H 'cache-control: no-cache' \ -d ' [ { "id": "36c11a6e-a43a-427c-9c28-90352b369d79", "name": "test", "description": "${role_create-client}", "composite": false, "clientRole": true, "containerId": "a48108f0-8465-4f91-8a90-39c72f1a05b8" } ]
Get latest tag commit from bitbucket api 2.0
I am trying to create a utility tool for which I need to get the latest tag committed to a specific repo. I have tried so far: curl -X GET \ https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags \ -H 'Accept: */*' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Authorization: Basic encodedpasswd' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Host: api.bitbucket.org' What I get in return is paginated response, like this: { "pagelen": 10, "values": [ { "name": "release-1.2", "links": { }, "tagger": { }, "date": "2019-11-15T11:53:56+00:00", "message": "[maven-release-plugin]copy for tag release-1.2\n", "type": "tag", "target": { } }, { "name": "release-1.3", "links": { }, "tagger": { }, "date": "2019-11-20T07:53:51+00:00", "message": "[maven-release-plugin]copy for tag release-1.3\n", "type": "tag", "target": { } } ], "page": 1 } Now as per the documentation I have referred through here, tags are specially ordered when returned, but I am confused as to why the value release-1.3 is not first in the response. I think I am missing something. Or if this is the expected order, how can I achieve the tags sorted on date attribute, to get the latest tag.
So I was able to solve this by using sort on attribute target.date. curl -X GET \ https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags?sort=target.date \ -H 'Accept: */*' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Authorization: Basic encodedpasswd' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Host: api.bitbucket.org'
Creating a tag with the Bitbucket Server API fails
I'm trying to use the Bitbucket Server RST API to create a new tag for a specific commit (represented by a hash). Please note that I use basic auth but don't write it to my examples below. What I've got is an HTTP 500 response. curl -XPOST 'http://<server>/rest/api/latest/projects/p1/repos/r1/tags' -d '{ "name": "my-new-tag", "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b" }' I also tried: curl -XPOST 'http://<server>/2.0/repositories/username/r1/refs/tags' -d '{ "name": "my-new-tag", "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b" }' But in this case the request ends up in an HTTP 404 and I think that's because this is not a Bitbucket Server URL.
You can try this way: curl -X POST -k -H 'Content-Type: application/json' -s -u <Your Account>:<Your password> -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{ "name": "my-new-tag", "target":{ "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b" } }' or curl -X POST -k -H 'Content-Type: application/json' Authorization: Basic <<Authentication String>>' -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{ "name": "my-new-tag", "target":{ "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b" } }'