Fixes Simply.com to use REST API version 2 with Basic Auth

This commit is contained in:
Nikolaj Brinch Jørgensen 2022-03-10 11:13:38 +01:00
parent 7fae5553a8
commit 227d62a5dc

View File

@ -5,8 +5,8 @@
#SIMPLY_AccountName="accountname" #SIMPLY_AccountName="accountname"
#SIMPLY_ApiKey="apikey" #SIMPLY_ApiKey="apikey"
# #
#SIMPLY_Api="https://api.simply.com/1/[ACCOUNTNAME]/[APIKEY]" #SIMPLY_Api="https://api.simply.com/2/"
SIMPLY_Api_Default="https://api.simply.com/1" SIMPLY_Api_Default="https://api.simply.com/2"
#This is used for determining success of REST call #This is used for determining success of REST call
SIMPLY_SUCCESS_CODE='"status":200' SIMPLY_SUCCESS_CODE='"status":200'
@ -237,12 +237,18 @@ _simply_rest() {
_debug2 ep "$ep" _debug2 ep "$ep"
_debug2 m "$m" _debug2 m "$m"
export _H1="Content-Type: application/json" basicauth=$(printf "%s:%s" "$SIMPLY_AccountName" "$SIMPLY_ApiKey" | _base64)
if [ "$basicauth" ]; then
export _H1="Authorization: Basic $basicauth"
fi
export _H2="Content-Type: application/json"
if [ "$m" != "GET" ]; then if [ "$m" != "GET" ]; then
response="$(_post "$data" "$SIMPLY_Api/$SIMPLY_AccountName/$SIMPLY_ApiKey/$ep" "" "$m")" response="$(_post "$data" "$SIMPLY_Api/$ep" "" "$m")"
else else
response="$(_get "$SIMPLY_Api/$SIMPLY_AccountName/$SIMPLY_ApiKey/$ep")" response="$(_get "$SIMPLY_Api/$ep")"
fi fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then