Why can't I enable or disable my GlassFish application through the REST API? - glassfish

When I submit a REST request, EG: (included auth is for admin/adminadmin)
curl -ik -X POST -H "Accept: application/json"
-H "Authorization: Basic YWRtaW46YWRtaW5hZG1pbg=="
https://localhost:4848/management/domain/applications/application/MyApp/enable
GlassFish just rejects the request:
HTTP/1.1 400 Bad Request
Content-Length: 0
Date: Wed, 17 Jul 2013 10:33:06 GMT
Connection: close
What am I doing wrong?
I've used the GET method to check the command parameters and they're all optional.

From: http://docs.oracle.com/cd/E26576_01/doc.312/e24928/general-administration.htm
REST requests that add, update, or delete objects must specify the X-Requested-By header with the value "GlassFish REST HTML interface".
So EG:
curl -ik -X POST -H "Accept: application/json"
-H "Authorization: Basic YWRtaW46YWRtaW5hZG1pbg=="
-H "X-Requested-By: GlassFish REST HTML interface"
https://localhost:4848/management/domain/applications/application/MyApp/enable

Based on the answer above, ajusted for those who try to do it with the successor of Glassfish - the Payara Server:
Enable App
curl -ik -X POST \
-H 'accept: application/json;charset=UTF-8' \
-H 'authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'x-requested-by: GlassFish REST HTML interface' \
--data target=server \
--url https://localhost:4848/management/domain/applications/application/awesomeApp/enable
Disable App
curl -ik -X POST \
-H 'accept: application/json;charset=UTF-8' \
-H 'authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'x-requested-by: GlassFish REST HTML interface' \
--data target=server \
--url https://localhost:4848/management/domain/applications/application/awesomeApp/disable

Related

BigCommerce API Order Update What Scope is Required?

I am trying to update the status of an order.
curl -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-H "X-Auth-Client: <auth client>"
-H "X-Auth-Token: <auth token>"
-H "X-Custom-Auth-Header: <auth header>"
https://api.bigcommerce.com/stores/<store hash>/v2/orders/14222
-d '{"status_id":2}'
I am getting the error:
{"status":403,"title":"You don't have a required scope to access the endpoint","type":"https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes","errors":{}}
We are using the same authorization that we use on all our other commands, which work fine.
Any ideas why it's saying we don't have the required scope?
Update: Try this Code with your Creds
Note: Check the value of Auth Token & Auth Client ID. Or, try by removing Auth Client ID (If invalid) as it is optional to BigCommerce APIs.
curl --request PUT \
--url https://api.bigcommerce.com/stores/<storehash>/v2/orders/14222 \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-auth-token: <OAuthToken Value>' \
--data '{"status_id":11}'
OR
curl -X PUT \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Auth-Token: <oauth_token>" \
-H "X-Custom-Auth-Header: <custom_header_value>" \
https://api.bigcommerce.com/stores/<store_hash>/v2/orders/14222 \
-d '{"status_id":2}'

Can we handle multipart request with jar file in karate API automation tool? [duplicate]

This question already has an answer here:
How to make proper multipart request using Karate when file is in --form?
(1 answer)
Closed 2 years ago.
I am trying to use jar file as multiform data in karate and the following is my sample request
Given path 'myBaseurl/v2/Import'
And multipart file myFile = {read: 'path/to/my/jar/myJar.jar', filename: 'myJar.jar', contentType: 'multipart/form-data'}
And header Authorization = basicAuthToken
And method post
Then status 200
Does karate support jar as multiform data?
below is the cURL
curl -X POST \
https:<URL>/v2/Import \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic <XXX>' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 4526292' \
-H 'Content-Type: multipart/form-data' \
-H 'Cookie: JSESSIONID=<XXX>; AWSALB=<XXX>' \
-H 'Host: <HOST>' \
-H 'Postman-Token: <XXX>,<XXX>' \
-H 'User-Agent: PostmanRuntime/7.20.1' \
-H 'cache-control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YxxxxrZu0gW' \
-F '=#/<C:\absolute path to nm>.jar'
Yes, Karate supports any type of (binary) file as multiform data.

Seting a Curl command to run in a Zapier Webhook

I'm trying to find the way to run cURL query in Zapier webhook, but I can't seem to figure it out. How would I enter this in the Webhook?
curl 'https://api.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://api.com' -H 'access_token: <my token>' --data-binary '{"query":"{\n booking(booking_id: \"11111\"){\n user{\n name\n }\n body\n }\n}\n"}' --compressed
This is the error I'm getting:
You need to put query in the left box under Query String Params. query is the key, the value is {\n booking(book.... You don't need quotes, either.

GoCD POST requests return "The resource you requested was not found!"

I have GoCD instance and want to automate regular actions like scheduling pipelines and checking pipelines statuses using GoCD API.
When I do GET request it works:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/status' \
-u 'kagarlickij:Pa$$w0rd' | jq
..but when I do POST request it returns "The resource you requested was not found!":
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/pause' \
-u 'kagarlickij:Pa$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' -H 'Content-Type: application/json' \
-X POST -d '{"pause_cause": "Investigating build failures"}' | jq
..another POST example:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/schedule' \
-u 'kagarlickij:P#$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' -H 'Content-Type: application/json' \
-X POST -d #gocd.json | jq
json content:
{
"environment_variables": {},
"materials": {},
"update_materials_before_scheduling": false
}
Any ideas how pipelines could be started using API?
Some GoCD API calls require 'Confirm': 'true' header.
In you case, you can try running curl like this:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/pause' \
-u 'kagarlickij:Pa$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' \
-H 'Content-Type: application/json' \
-H 'Confirm: true' \
-X POST -d '{"pause_cause": "Investigating build failures"}' | jq
I can recommend my lib yagocd for GoCD, which takes cares about version incompatibilities and makes working with GoCD API much easier.
The answer turned out to be very simple - that API actions require GoCD v18.2.0 but I had v18.0.0
After upgrade API calls work as expected

Authentication of arangodb APIs of dbserver and agency is failed

I uses the arangodb(0.9.3) to start cluster(current version 3.2.1).
there are some problemsin authentication.
query1 post to coordinator(port=8529) with basic auth, response 200
curl -X GET \
http://xx.xx.xx.xx:8529/_db/KnowledgeGraph/_api/collection/CarInfo \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 897691e4-c4fc-5588-b217-0da53bc368ba'
query2 post to agency(port=8531) with basic auth, response 401
curl -X GET \
http://xx.xx.xx.xx:8531/_api/agency/config \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 5160250f-4471-84aa-e377-bd0b99ba9926'
I want to use logger-follow to monitor the change of data in cluster. query3 post to dbserver(port=8530) with basic auth, response 401. If my cluster start without --auth.jwt-secret /my/path/to/jwt, such query has response 200.
curl -X GET \
'http://xx.xx.xx.xx:8530/_api/replication/logger-follow?from=0' \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 11b09c7f-85b1-4ed3-ca78-f28cf86c331b'
Is there some difference of authentication between agency/dbserver with coordinator?
Or is there something wrong with authentication of agency/dbserver?