Modification in CURL request to upload image to RoR - ruby-on-rails

I am able to upload image to RoR application(using carrierwave for image upload) through CURL request,
curl -v -H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-F "photo[display_photo]=#/home/Pictures/images.jpeg" \
-F "photo[name]=Flower" http://localhost:3001/photos.json
But i wanted to modify above command as,
curl -v -H "enctype: multipart/form-data" \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-d '{"photo":{
"name":"Flower",
"display_photo":#"/home/Pictures/images.jpeg"
}}' POST http://localhost:3001/photos.json
How to achieve it!!!

The question looks incomplete. But i guess what you are trying to achieve is somthing similar to what is asked in this question:
Curl request to upload image from local machine to ruby on rails application
Note: Do remember, asking a question on stackoverflow, or any of its variants, do keep in mind another person with the same problem faced by you. So make questions as clear as possible, such that it helps you as well as others in the future. A few links before you frame a question:
How do I ask a good question?

Related

Bitbucket API Update Pipeline Variable

I'm unable to successfully update a repository variable and not sure why it's not working.
I've been able to get all the necessary IDs through the API and am making the following curl request:
curl -X PUT "https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/pipelines_config/variables/{variable_uuid}" -H 'Content-Type: application/json' -d '{"value":"{value}","key":"{name}"}'
From this I get:
{"type": "error", "error": {"message": "Resource not found"}}
Does anyone have any ideas what's missing as I've tried changing everything I can think of but with no luck
- curl -v -X PUT "https://api.bitbucket.org/2.0/repositories/$ORG_OR_WORKSPACE/$REPO/pipelines_config/variables/\{$HASH_VARIABLE\}" -H "Content-Type:application/json" -d "{\"key\":\"$VARIABLE_NAME\", \"value\":\"$VARIABLE_VALUE\" }" --user $PIPELINE_APP_PASS
The actual hash needs to be encased in brackets {} which are escaped with \
Try running the command from terminal to make sure you can update your variable. You might want to create a user app password with access, should be username:password
Found it
#!/bin/bash
set -x
export USER_NAME=user_name
export PASSWORD=password
curl --user "$USER_NAME":"$PASSWORD" 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/' -H 'Content-Type: application/json'
curl -vX PUT -u "$USER_NAME":"$PASSWORD" --url 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/%7B21212121-2d1e-201a-21c2-212121a21212%7D' -H 'Content-Type:application/json' -d "{\"value\":\"new_value\", \"key\":\"variable\"}"
https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-variable-uuid/qaq-p/1496735

How to execute "docker checkpoint create container_id checkpoint_id" using curl?

At the moment of writing, docker checkpoint feature is still in experimental phase so there is no official (HTTP) API documentation. Nonetheless, there is an endpoint on the docker daemon that can accept an HTTP request, as it is the one that docker cli uses.
Based on the related docker source code it should be something like
sudo curl -X POST --unix-socket /var/run/docker.sock http://localhost/v1.32/containers/20fb4f16ff10/checkpoints
but this does not work. Any ideas what I may be missing?
The create options is missing.
curl --unix-socket /var/run/docker.sock \
-H "Content-Type: application/json" \
-d '{"CheckpointID": "noting"}' \
-X POST http:/v1.32/containers/20fb4f16ff10/checkpoints

How to change neo4j database password

I am trying to change my default user password to database. I've tried this:
$ curl -H "Content-Type: application/json" \
-X POST \
-d '{"password":"password"}' \
-u neo4j:neo4j \
http://localhost:7474/user/neo4j/password"
but it doesn't let me and gave me this error:
Invalid input 'u': expected 'r/R' or 'a/A' (line 1, column 2 (offset:
1)) "curl -H "Content-Type: application/json" -X POST -d
'{"password":"qazWSXEDCRFV!1"}' -u neo4j:neo4j
http://localhost:7474/user/neo4j/password"" ^
How to fix this issue?
curl -H "Content-Type: application/json" -XPOST -d '{"password":"new password"}' -u neo4j:neo4j http://localhost:7474/user/neo4j/password
just worked for me (Neo4j 3.0.x)
If you use GUI, execute :server change-password. It will call changing password dialog where you have to type your current pass and a new one.

export swagger api definition from api gateway via http request?

I am trying to export api definition from api gateway using the following http request following the documentation of AWS. Any idea why is it not working?
curl -i -X GET -H "Accept: application/json" "https://apigateway.ap-northeast-1.amazonaws.com/restapis/<api-id>/stages/<stage-name>/exports/swagger"
Error:
HTTP/1.1 403 Forbidden
{"message":"Missing Authentication Token"}
I would recommend that you use the aws cli for exporting swagger instead (http://docs.aws.amazon.com/cli/latest/reference/apigateway/get-export.html).
If you want to use a curl command to export swagger, you will need to sign the request with SigV4 (http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html?shortFooter=true) . I was able export a swagger successfully with the below command
curl -X GET -H "Accept: application/json" -H "Host: apigateway.us-east-1.amazonaws.com" -H "Authorization: AWS4-HMAC-SHA256 Credential=<ACCESS_ID>/20160616/us-east-1/apigateway/aws4_request, SignedHeaders=accept;content-type;host;x-amz-date, Signature=<SIG_V4_SIGNATURE>" -H "Content-Type: application/x-www-form-urlencoded" -H "X-Amz-Date: 20160616T173231Z" -H "Cache-Control: no-cache" "https://apigateway.us-east-1.amazonaws.com/restapis/<REST_API_ID>/stages/<STAGE_NAME>/exports/swagger"

[topic neo4j REST API]Can't Remove All Entries With a given node

I create node
node[16]{name:"test01",key01:"value01",key02:"value02"}
when i exc
curl -i -H "Accept: application/json" -X DELETE http://127.0.0.1:7474/db/data/index/node/kvnode/16
I still see node information:
node[16]{name:"test01",key01:"value01",key02:"value02"}
why?
Your REST call isn't right, it only deletes the index, not the node. If you want to delete the node, use this:
curl -i -H "Accept: application/json" -X DELETE http://127.0.0.1:7474/db/data/node/16

Resources