Phabricator API - Create a Project is not working - phabricator

curl -k -s -X POST "https://phabricator_URL.eu/api/project.edit" \
-d api.token=api-myapitoken \
-d members.add=TestMember \
-d name=TestProject \
-d objectIdentifier= | jq -r
ERROR receive:
{
"result": null,
"error_code": "ERR-CONDUIT-CALL",
"error_info": "API Method \"project.edit\" does not define these parameters: 'members.add', 'name'."
}
Link Used:
https://secure.phabricator.com/conduit/method/project.edit/

You have to specify members.add as part of a list of transactions, and the users to add must also be a list:
curl -k -s -X POST "https://phabricator_URL.eu/api/project.edit" \
-d api.token=api-myapitoken \
-d transactions[0][type]=name
-d transactions[0][value]=TestProject \
-d transactions[1][type]=members.add \
-d transactions[1][value][0]=PHID-USER-5555 \
-d objectIdentifier= | jq -r
If you submit the API call you want to make through the conduit doc page, it will display the curl call needed to perform those same actions.

Related

Exclude Path for GoAccess

I am trying to exclude some Paths in GoAccess to get an better result for my WordPress Installation.
So I am doing this:
#!/bin/sh
set -x
zcat -f /var/log/nginx/access-blog.log* > /var/www/serverstats/work/access-parsed.log | grep -Ev '/wp-config.php|/xmlrpc.php|/wp-json|/adminer|/robots.txt|/app-ads.txt|/ads.txt|/wp-login.php|//feed|/?author=|/wp-content|/wp-admin|/rss|/api/v1|/wp-cron.php' /var/www/serverstats/work/access-parsed.log |goaccess \
--log-file=/var/www/serverstats/work/access-parsed.log \
--log-format=COMBINED \
--exclude-ip=0.0.0.0 \
--geoip-database=/var/www/serverstats/GeoLite2-City.mmdb \
--ignore-crawlers \
--hide-referer=*.dasnetzundich.de \
--hide-referer=dasnetzundich.de \
--browsers-file=/var/www/serverstats/crawler.list \
--anonymize-ip \
--persist \
--db-path=/var/www/serverstats/db \
--real-os \
--output=/var/www/serverstats/index.html
rm /var/www/serverstats/work/access-parsed.log
set +x
but that wont work. Can anyone help me to get it working?
Thanks
Lars
I tried these Scripts and it wont exclude the path like /xmlrpc.php and wp.login.php.
It would be amazing if I can filter the output from GoAccess.

Using grep to remove from verbose call and saving in a shell script function

I have a curl put request that I can use some unix command to see the stdout and stderr from.
If I add the line 2>&1 | grep -v "Authorization" At the end of my curl request, I can see the verbose output from my curl in my CLI minus a line that starts with "Authorization"
I tried creating a function with the above command, but when I call that function at the end of my curl request (like below) it no longer removes the "Authorization" line.
function remove_item_from_verbose {
2>&1 | grep -v "Authorization"
}
echo -e "\n +++ Creating '$TENANT' tenant:\n"
# Create tenant
curl -L -X PUT "http://localhost:$HOST_PORT/admin/v2/tenants/$TENANT" \
--verbose \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $AUTHORIZATION" \
--data-raw "{\"allowedClusters\": [\"$CLUSTER\"]}" remove_item_from_verbose
AFAIK functions do work like that. What you are trying to so is add extra details to your command. You can do it like that:
#!/bin/bash
remove_item_from_verbose="2>&1 | grep -v \"Authorization\""
echo -e "\n +++ Creating '$TENANT' tenant:\n"
# Create tenant
eval curl -L -X PUT "http://localhost:$HOST_PORT/admin/v2/tenants/$TENANT" \
--verbose \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $AUTHORIZATION" \
--data-raw "{\"allowedClusters\": [\"$CLUSTER\"]}" "$remove_item_from_verbose"
Like this, $remove_item_from_verbose becomes a suffix of your command.
Note the addition of eval in front of curl, it is required to have this suffix treated as part of the command.

httr GET request with large query list

I have translated this cURL command into a httr:GET() request in R. However, I'm still getting a 400 error as an invalide request. I double checked using the normal cURL command in a git terminal and it worked perfectly.
Where is the problem in my translation of cURL command to R httr:GET query? Do I need to account for the -G at the end of the cURL in my GET request?
$ curl https://api.goclimate.com/v1/flight_footprint \
-u YOUR_API_KEY: \
-d 'segments[0][origin]=ARN' \
-d 'segments[0][destination]=BCN' \
-d 'segments[1][origin]=BCN' \
-d 'segments[1][destination]=ARN' \
-d 'cabin_class=economy' \
-d 'currencies[]=SEK' \
-d 'currencies[]=USD' \
-G
In R:
r <- GET("https://api.goclimate.com/v1/flight_footprint/",
authenticate(api.key,""),
query = list(
"segments[0][origin]"="ARN",
"segments[0][destination]"="BCN",
"segments[1][origin]"="BCN",
"segments[1][destination]"="ARN",
"cabin_class"="ecomony",
"currencies[]"="SEK",
"currencies[]"="USD"))

How to place a file on salt master via salt-api

I want to place a file a file on salt-master via salt-api. I have configured salt-api using rest cherrypy and configured a custom hook for it. I wanted to explore the use-case where we can transfer the file first to salt-master and secondly distribute it to minions. I'm able to achieve the second part but not been able to post data file to the API.
Here is one way to do it using file.write execution module.
First login and save the token to a cookie file (I had to change eauth to ldap, auto didn't work for some reason):
curl -sSk http://localhost:8000/login \
-c ~/cookies.txt \
-H 'Accept: application/x-yaml' \
-d username=USERNAME\
-d password=PASSWORD \
-d eauth=auto
Now run a job to create a file on the salt-master (assuming your salt-master is also running a salt-minion):
curl -sSk http://localhost:8000 \
-b ~/cookies.txt \
-H 'Accept: application/x-yaml' \
-d client=local \
-d tgt='saltmaster' \
-d fun=file.write \
-d arg='/tmp/somefile.txt' \
-d arg='This is some example text
with newlines
A
B
C'
Note that the spacing used in your command will affect how the lines will show up in the file, with the example above is gives the most aesthetically pleasing result.

How to get http request from curl?

I've got a curl request which looks like:
curl -s http://someurl1.com -H 'Accept: application/json' -u 'emv:LgKrAVkFf2c6mr4DFBQUdjBK' -d grant_type='password' -d scope='offline_access' -d username='datafiles#random.com' -d password='456Qwer()' -d acr_values='tenant:sdfdfsdf-e5e7-42d5-9881-sdfsdf' | python -m json.tool
How can I construct a simple HTTP request from it? I've tried to import it with postman but got Error while importing Curl: Zero or Multiple option-less arguments. Only one is supported (the URL)
curl http://someurl1.com -H 'Accept: application/json' -u 'emv:LgKrAVkFf2c6mr4DFBQUdjBK' -d grant_type='password' -d scope='offline_access' -d username='datafiles#random.com' -d password='456Qwer()' -d acr_values='tenant:sdfdfsdf-e5e7-42d5-9881-sdfsdf'
this string can be imported by Postman.

Resources