export swagger api definition from api gateway via http request? - swagger

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"

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

curl Error in Jenkins Pipeline - URL not Found

sh '''curl -X POST -H "Content-Type: application/json" -d '{ "name": "'"$GroupName"'", "deletable": "true"}’'https://"${username}":"${password}"#bitbucket.com/rest/api/1.0/admin/groups?name="$GroupName" '''
I use the. above in the Jenkins pipeline. on Executing I am getting an error
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
just figured out
This is an API call from Jenkins to Create Group in BB.
sh '''curl -X POST -H "Content-Type: application/json" -d '
{
"name": "'"$GroupName"'",
"deletable": "true"
}' https://"${username}":"${password}"#bitbucket.com//rest//api//1.0//admin//groups?name=$GroupName'''
}
replace your bitbucket URL.

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.

Unable to connect to Jira by basic authentication

I tried to connect to Jira by basic authentication as discussed here, but had 401 error.
Here password and login are the same c27115#trbvm.com
My curl
curl -D- -u c27115#trbvm.com:c27115#trbvm.com -X GET -H "Content-Type: application/json" https://jira.atlassian.com/rest/api/2/project
curl -D- -X GET -H "Authorization: Basic YzI3MTE1QHRyYnZtLmNvbTpjMjcxMTVAdHJidm0uY29t" -H "Content-Type: application/json" "https://jira.atlassian.com/rest/api/2/project"
Here the response result.
Can you help me?
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, username.":".password);
This shoud do it.

Modification in CURL request to upload image to RoR

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?

Resources