-
Ask a Question!JSON [ I'm trying to create a stack using the /stacks/create/swarm/file API, but I get the following return. {"message":"Invalid request payload","details":"Invalid Env parameter"} How can I include semicolons? Portainer version : 2.21.5 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @Aaron-Bae You need to make sure your JSON is formatted correctly, you can see an example in our API Docs - https://app.swaggerhub.com/apis/portainer/portainer-ce/2.21.5#/stacks/StackCreateDockerSwarmFile |
Beta Was this translation helpful? Give feedback.
-
I was able to solve the problem. Instead of using "-F" I changed it to "--form-string" so that I can use the semi-colon inside my $ENV_JSON. Before: After: |
Beta Was this translation helpful? Give feedback.
I was able to solve the problem. Instead of using "-F" I changed it to "--form-string" so that I can use the semi-colon inside my $ENV_JSON.
Before:
curl -s -X POST curl -s -X POST "$PORTAINER_URL/stacks/create/swarm/file?endpointId=$ENDPOINT_ID"
-H "X-API-Key: $ACCESS_TOKEN"
-H "Content-Type: multipart/form-data"
-F "Name=$STACK_NAME"
-F "SwarmID=$SWARM_ID"
-F "file=@$COMPOSE_FILE"
-F "Env=$ENV_JSON"
-F "Prune=true"
After:
curl -s -X POST "$PORTAINER_URL/stacks/create/swarm/file?endpointId=$ENDPOINT_ID"
-H "X-API-Key: $ACCESS_TOKEN"
-H "Content-Type: multipart/form-data"
-F "Name=$STACK_NAME"
-F "SwarmID=$SWARM_ID"
-F "file=@$COMPOSE_FILE"
--form-string "Env=$ENV_JSON"
-F "…