I'm trying to implement a gradle task that sends a HTTPS request to my backend. For authentication, I have to attach a client certificate to the request.
Does anybody know how to do this? I'm currently using the library http-builder-ng but haven't figured out yet to achieve this.
Well I dont know your library but is sh an option for you?
Gradle features an Exec task to execute shell as task.
You could do curl there:
curl -v \
--cacert ./ca.pem \
--key ./admin-key.pem \
--cert ./admin.pem \
https://xxxx/api/v1/
In build.gradle it could look like this:
(url is a gradle project property, can be given via -P flag during build or in gradle.properties.)
task httpsRequest(type:Exec) {
commandLine 'sh', '-c', "curl -v --cacert ./ca.pem --key ./admin-key.pem --cert ./admin.pem '${url}'"
}
Related
I'm trying to download a private repository as .zip via cmd, I can do pull/push and create branches on this repository but i'm not sure if that makes me a collaborator, i was able to achieve this with a public repository like this curl -L -o master.zip http://github.com/zoul/Finch/zipball/master/
I also tried curl -u 'MyUsername' -L -o master.zip https://github.com/{repo owner}/{repo name}/zipball/master/ but all I got was a .zip and the message "The archive is either in unknown format or damaged", what am I missing?
I found what I was looking for. I generated a personal access token in Github with all the necessary permissions (initially I didn't give all the permissions I needed) and with the following structure I was able to download the zip from the master branch:
curl -H "Authorization: token MyToken" -L -o master.zip https://github.com/repoOwner/repoName/zipball/master/
With the github API, I got information about it:
curl -i -H "Authorization: token MyToken" https://api.github.com/repos/repoOwner/repoName
Tried the following curl command for uploading a local turtle file to GraphDB (free version), running at http://localhost:7200/.
curl -X POST 'http://localhost:7200/repositories/testrepository1/statements' -H "Content-Type:text/turtle" -T "/home/Desktop/onto.ttl"
Eventhough this curl command doesn't return any error when executed, the local file onto.ttl is not uploaded to testrepository1
Iam using graphDB free with version 9.7.0.
It'll be grateful if someone help me with this. Thanks in advance!
You are using a wrong mime type - it should be application/x-turtle instead of text/turtle. The request will look something like this:
curl -X POST -H "Content-Type:application/x-turtle" -T "/home/Desktop/onto.ttl" http://localhost:7200/repositories/testrepository1/statements
I'm following the instructions to locally test lambda container https://docs.aws.amazon.com/lambda/latest/dg/images-test.html
but I am unable to do so.
I've created a sample project to reproduce it https://gitlab.com/sunnyatticsoftware/sandbox/lambda-dotnet5-webapi (see the README for step by step on its generation)
Basically I am using an Amazon dotnet template that generates an AWS Lambda function as a .NET 5 web api using containers.
It's all good with the project. The Dockerfile is described as
FROM public.ecr.aws/lambda/dotnet:5.0
WORKDIR /var/task
COPY "bin/Release/net5.0/publish" .
Now I want to test it locally using the Amazon Lambda Runtime Interface Emulator (RIE) and these are the steps I follow:
Build project with dotnet build -c Release
Publish artifacts with dotnet publish -c Release
Build docker image with docker build -t lambda-dotnet .
Download the RIE with
mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie
I can see the emulator downloaded properly
ls -la ~/.aws-lambda-rie/aws-lambda-rie
-rw-r--r-- 1 diego.martin 1049089 8155136 Feb 22 14:32 /c/Users/diego.martin/.aws-lambda-rie/aws-lambda-rie
Run the emulator passing the lambda image
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 --entrypoint /aws-lambda/aws-lambda-rie lambda-dotnet:latest
Here is when I get the error
12997dddc6e50aca3020527be30a1479eee9ceef412ab5009b99e9eb8cf1fa67
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "C:/Users/diego.martin/AppData/Local/Programs/Git/aws-lambda/aws-lambda-rie": stat C:/Users/diego.martin/AppData/Local/Programs/Git/aws-lambda/aws-lambda-rie: no such file or directory: unknown.
What am I missing? I am not specifying any entrypoint because I don't have any.
PS: The last step would be to send some lambda event to my container's function with
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
The lambda docker images for dotnet already include the RIE, so it's enough with the following (see repo with further details):
To build image
docker build -t lambda-dotnet:latest .
To run it
docker run -p 9000:8080 lambda-dotnet "LambdaDotNet5::LambdaDotNet5.LambdaEntryPoint::FunctionHandlerAsync"
And then to test it, I can use CURL from a different terminal
curl -vX POST http://localhost:9000/2015-03-31/functions/function/invocations -d #test_request.json --header "Content-Type: application/json"
and in the test_request.json file I can have the json for the event I want to send to the lambda.
I am trying to pull a project ID using gitlab REST API v4, but when I issue the curl command, I get this error:
"jobs:test:script config should be a string or an array of strings"
The command is this one:
curl -k -H "PRIVATE-TOKEN: PRIVATE-TOKEN" "https://gitlab.nbg992.poc.dcn.telekom.de/api/v4/projects?search=$CI_PROJECT_NAME"
I tried to single quote it:
'curl -k -H "PRIVATE-TOKEN: PRIVATE-TOKEN" "https://gitlab.nbg992.poc.dcn.telekom.de/api/v4/projects?search=$CI_PROJECT_NAME"'
But when I do it, it removes the failure, but the command is ignored.
So I tried to eval it like this:
eval - 'curl -k -H "PRIVATE-TOKEN: PRIVATE-TOKEN" "https://gitlab.nbg992.poc.dcn.telekom.de/api/v4/projects?search=$CI_PROJECT_NAME"'
When I do it, the failure its produced again:
"jobs:test:script config should be a string or an array of strings"
Any clue how should I issue the curl command? I think what is causing the failure is the colon within the "PRIVATE-TOKEN: PRIVATE-TOKEN"
This worked for me
Declare Job variables in variables sections eg:
variables:
PRIVATE-TOKEN: "TokenValue"
PRIVATE_HEADER: "PRIVATE-TOKEN: ${PRIVATE-TOKEN}"
Then under Script Section of the CI file used Curl command as follows
script:
curl -k -H ${PRIVATE_HEADER} "https://gitlab.nbg992.poc.dcn.telekom.de/api/v4/projects?search=${CI_PROJECT_NAME}
Using the {} braces around variable names made sure that ":" issue doesn't show up
I want to upload my APK to Saucelabs, How can I do that?
Is there any tab do so ?
I am trying with Curl command as well, which is not working for me
Yes, U have to use curl command correctly.
Use below Link to download curl :
http://curl.haxx.se/download.html
After that use below curl command :
curl -u YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/YOUR_SAUCE_USERNAME/YOUR_ANDROID_APP.apk