curl post fail all time - api

hello i'm trying this guide but it fail all time
https://github.com/ubahnverleih/WoBike/blob/master/Beam.md
To login, I need to get OTP code but i can't access to it
curl -d "phoneNumber=[phonenumber]countryCode=+[countrycode]" \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
but it sends message like this
{"success":false,"message":"There was some error","response":{},"error":"","data":{}}
i don't know why this fail
is my code grammarly wrong?

The tutorial and the curl command say it's an application/json and you are passing an incorrect format in the data. Pay attention at the beginning of the command curl -d ...
Correct:
curl -d '{"phoneNumber":"<phone-number>","countryCode":"+<country-code>"}' \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
Wrong:
curl -d "phoneNumber=[phonenumber]countryCode=+[countrycode]" \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
Execution:
curl -d '{"phoneNumber":"123123123","countryCode":"+55"}' \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
{"message":"PhoneVerificationServiceErrorDomain","messageKey":1,"messageArgs":"{"status":400,"message":"Invalid
parameter To:
+55123123123","code":60200,"moreInfo":"https://www.twilio.com/docs/errors/60200"

Related

Curl - always the last Argument is missing, why?

When i use the following Curl command in Terminal on Mac:
curl "https://api-free.deepl.com/v2/glossaries" \
--header "Authorization: DeepL-Auth-Key 0c9649a5-e8f6-632a-9c42-a9eee160c330:fx" \
--data-urlencode "name=My Glossary" \
-d "source_lang=en" \
-d "target_lang=de" \
--data-urlencode "entries=Hello! Guten Tag!" \
-d "entries_format=tsv"
I get the following Error:
{"message":"Bad request","detail":"Missing or invalid argument: entries_format"}
But this is an example Request on der Documentation, so it should work.
The tab character in the entries parameter is encoded incorrectly. Modify that line to:
--data-urlencode $'entries=Hello!\tGuten Tag!' \
PS: you should reset your authentication key as it is exposed in the code above.

invalid_payload while passing variable in slack POST CURL command in gitlab.ci.yml

I am keep on getting invalid_payload and not able to trigger email to Slack channel.
send_email:
stage:notify
when:always
variables:
PASSED_COUNT: "'{\"passed\":1}'"
DEPLOY_CURL_COMMAND: 'curl -X POST -H "Content-type:application/json" --data $PASSED_COUNT https://hooks.slack.com/services/xxxxx/xxxxxxx/..'
script:
- echo "Testing Platform"
- echo $DEPLOY_CURL_COMMAND
- 'eval "$DEPLOY_CURL_COMMAND"'
- curl -X POST -H 'Content-type:application/json' --data '{"text":"'$PASSED_COUNT'"}' https://hooks.slack.com/services/xxxxx/xxxxxxx/..'

REST call in vb.net: how to pass the data in cURL

How I can convert the below code in VB.net. Thank you in advance.
$ curl -X POST https://www.drillster.com/daas/oauth/token \
-d 'client_id=874a16d4ac764ce4a545f0cca4584c63' \
-d 'client_secret=5782b2e7532b48b5a0798f2ad6644614' \
-d 'grant_type=authorization_code' \
-d 'code=cIEL8h'

script cURl API: message":"Invalid signature"

I'm trying to use OVH API to update DNS zone entries.
I'm using shell script with cURL command but I get this error :
{"message":"Invalid signature","httpCode":"400 Bad Request","errorCode":"INVALID_SIGNATURE"}
Here is the script :
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="POST"
HTTP_QUERY="https://api.ovh.com/1.0/domain/zone/domaine.fr/record"
HTTP_BODY=""
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type:application/json;charset=utf-8" \
-H "X-Ovh-Application:$OVH_APP_KEY" \
-H "X-Ovh-Timestamp:$TIME" \
-H "X-Ovh-Signature:$SIG" \
-H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" \
-d '{"fieldType":"TXT", "subDomain":"", "target":"VX=SPF"}'
But with this script works fine :
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="GET"
HTTP_QUERY="https://api.ovh.com/1.0/domain"
HTTP_BODY=""
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type:application/json;charset=utf-8" \
-H "X-Ovh-Application:$OVH_APP_KEY" \
-H "X-Ovh-Timestamp:$TIME" \
-H "X-Ovh-Signature:$SIG" \
-H "X-Ovh-Consumer:$OVH_CONSUMER_KEY"
The differences between these 2 scripts are :
HTTP_METHOD
HTTP_QUERY
DATA
Do you have an idea why?
Thanks
L.
Solution found below:
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="POST"
HTTP_QUERY="https://api.ovh.com/1.0/domain/zone/domaine.fr/record"
txt_type="TXT"
txt_field=""
txt_value='"XXXXXXXXXXXXXXX"'
HTTP_BODY="{"fieldType":"$txt_type","subDomain":"$txt_field","target":"$txt_value"}"
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN=$OVH_APP_SECRET"+"$OVH_CONSUMER_KEY"+"$HTTP_METHOD"+"$HTTP_QUERY"+"$HTTP_BODY"+"$TIME
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 -hex | cut -f 2 -d ' ' )
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type: application/json" \
-H "X-Ovh-Application: $OVH_APP_KEY" \
-H "X-Ovh-Timestamp: $TIME" \
-H "X-Ovh-Signature: $SIG" \
-H "X-Ovh-Consumer: $OVH_CONSUMER_KEY" \
--data "$HTTP_BODY"

Is it possible to do test state.apply through salt-api?

Is there a way to do:
salt '*' state.apply nginx test=True
through salt-api ?
I'm doing this:
curl -sSk http://salt:8000
-H 'Accept: application/x-yaml'
-H 'X-Auth-Token: token'
-d client=local
-d tgt='*'
-d fun=state.apply
-d arg=nginx
-d test=True
but it actually applies new state.
Thanks in advance!
what about curl -sSk http://salt:8000/run instead of curl -sSk http://salt:8000
and are you using \ at the end of each option?
otherwise it looks good, what version of salt are you running?
https://salt-sproxy.readthedocs.io/en/latest/salt_api.html <= good reading
Finally, I found a way to do state.apply through salt-api with test option.
All I needed was: -d arg='test='true''
Example of full request:
curl -sSk http://salt:8000 \
-H 'Accept: application/x-yaml' \
-H 'X-Auth-Token: token' \
-d client=local \
-d tgt='*' \
-d fun='state.apply' \
-d arg='nginx' \
-d arg='test='true''