With the following field configuration
#JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
When I run the project with java the result of printing the date is:
{"name":"test","date":"2021-11-20 23:12:12"}
However with native image:
mvn -T 1C package -Dpackaging=native-image -Pgraalvm
execute the binary:
./target/jackson-string-error
Sending post:
curl -X POST --location "http://localhost:8080/main" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"name\":\"test\",\"date\":\"2021-11-20 23:12:12\"}"
the result is:
{"name":"test","date":[2021,11,20,23,12,12]}
For some reason the date is not parsed.
Sample: https://github.com/j1cs/jackson-string-error
OS: Macos Big Sur
Micronaut version: 3.1.4
Graalvm version: 21.2.0.r11-grl
Issue github: https://github.com/micronaut-projects/micronaut-core/issues/6546
Update:
I made mi own serializer and still doesn't work.
I added one log to see if it goes through that class.
When I run the app with java it print the log fine:
02:31:46.585 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 1171ms. Server Running: http://localhost:8080
02:31:50.729 [default-nioEventLoopGroup-1-2] INFO me.jics.CustomDateSerializer - the formatter: yyyy-MM-dd HH:mm:ss
02:31:50.730 [default-nioEventLoopGroup-1-2] INFO me.jics.MainController - {"date":"2021-11-20 23:12:12","name":"test"}
But with the native image the log "the formatter" doesn't print:
02:30:23.601 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 29ms. Server Running: http://localhost:8080
02:30:28.561 [default-nioEventLoopGroup-1-2] INFO me.jics.MainController - {"name":"test","date":[2021,11,20,23,12,12]}
Solved by the micronaut framework team: https://github.com/micronaut-projects/micronaut-core/issues/6546
Related
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 am trying to add Pass/Fail status in Saucelabs whenever I run an Automated test but I can't figure out how shall I do it. I use Behat - Selenium Driver. I read the documentation but it didn't help me.
I tried to use the Saucelabs Rest API guide and I launch in my console the following
curl -X PUTĀ \
-s -d '{"passed":true}' \
-u https://USERNAME:APIKEY#saucelabs.com/rest/v1/users/USERNAME
But it doesn't work.
I think you need the session Id
ownCloud uses:
curl -X PUT -s -d "{\"passed\": $PASSED}" -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY https://saucelabs.com/rest/v1/$SAUCE_USERNAME/jobs/$SAUCELABS_SESSIONID
see: https://github.com/owncloud/core/blob/master/tests/travis/start_ui_tests.sh#L235
and this Id is pulled from the URL: https://github.com/owncloud/core/blob/master/tests/ui/features/bootstrap/FeatureContext.php#L171
but there might be better ways of getting it
I'm trying to execute a command in a running docker container through the Docker Engine API with cURL. I'm following the instructions in the API doc.First I create an exec instance and as a response I receive the ID of the created exec.
Then I use the this ID when I try to send a request to start this exec, which looks as follows:
$ curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -x POST "http:/v1.29/exec/myExecID/start"
But the response from that request is:
{"message":"page not found"}
This is my Docker version:
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:10:54 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:10:54 2017
OS/Arch: linux/amd64
Experimental: false
In the code in the Moby's repository, they call the absolutely same address.
Anyone else faced this problem ever before? I'll be glad if you share your experience.
Maybe it happens because you did not include the request body like this :
-d '{"Detach": false, "Tty": false}'
If you even get an error like below :
{"message":"No such exec instance '<ID>' found in daemon"}
That means you have not created an instance for exec. If so, you need to create a new instance
curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" \
-d '{"AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "DetachKeys": "ctrl-p,ctrl-q", "Tty": false, "Cmd": ["date"], "Env": ["FOO=bar", "BAZ=quux"]}' \
-X POST http:/v1.29/containers/fafe141c1a2b/exec
Output (example) :
{"Id":"70f08c296d460d2fe254ecd0f8e0416777a6b938bb74a325ffc76405d33d3526"}
After that then you can do exec as shown below :
curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" \
-d '{"Detach": false, "Tty": false}' \
-X POST http:/v1.29/exec/70f08c296d460d2fe254ecd0f8e0416777a6b938bb74a325ffc76405d33d3526/start
I've tried that way and it works, hopefully can help!
Something happened with my Drone configuration. It's not finding the environment variables since today. Until few days ago, I could run a pipeline, but today I can't.
This is the step into the pipeline:
pipeline:
[...]
sdk:
image: mycompany/swagger-codegen:latest
environment:
- API_SWAGGER_JSON_URL=http://api.mycompany.biz:9000/v1/swagger.json
- API_PACKAGE=com.mycompany.api
- API_GROUP_ID=com.mycompany.api
- API_ARTIFACT_ID=sdk
- API_VERSION=0.1-SNAPSHOT
when:
branch: master
commands:
- java -jar /usr/lib/swagger/swagger-codegen-cli.jar generate
-i ${API_SWAGGER_JSON_URL}
--api-package ${API_PACKAGE}
--invoker-package ${API_PACKAGE}.client
--model-package ${API_PACKAGE}.client.model
--group-id ${API_GROUP_ID}
--artifact-id ${API_ARTIFACT_ID}
--artifact-version ${API_VERSION}
-l java
-o ./swagger-codegen-source
- etc.
And this is what I get
+ java -jar /usr/lib/swagger/swagger-codegen-cli.jar generate -i --api-package --invoker-package .client --model-package .client.model --group-id --artifact-id --artifact-version -l java -o ./swagger-codegen-source
Exception in thread "main" io.airlift.airline.ParseArgumentsUnexpectedException: Found unexpected parameters: [java]
at io.airlift.airline.Cli.validate(Cli.java:148)
at io.airlift.airline.Cli.parse(Cli.java:116)
at io.airlift.airline.Cli.parse(Cli.java:97)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Look at the command. Every environment variable was substituted by an empty string. Am I doing something wrong?
You should use $variable or $${variable} instead of ${variable}
This is because drone interpolates runtime variables [1] into the yaml using ${variable} syntax. This behavior is similar to docker-compose which drone uses as a baseline for functionality and syntax.
[1] http://docs.drone.io/environment/
[2] http://docs.drone.io/secrets-not-working/#variable-expansion
I have the following curl command:
curl -k -u sandboxer:sandboxer -D- -X POST -H "Content-Type: application/json" --data
'{"jql":"project = BNAP AND resolution = null AND status != Resolved AND status != Rejected",
"maxResults":2 ,
"fields":["KEY","versions","description","status","resolution"]}'
https://127.0.0.1/rest/api/latest/search 1> newtest
I recieve a JSON object with meta-data,
{"expand":"schema,names"
,"startAt":0
,"maxResults":2
,"total":74
...
All I am intersted in is what follows, issues. I could take care of this in my application, but I am wondering if there is a way I could just tell JIRA 'Don't send me meta-data'. Is there?
Use the Speakeasy plugin to create a custom request/response as a Jira extension:
Speakeasy plugin
Installing Speakeasy
Developing Speakeasy Extensions