Bulk update api problem

INPUT=$PAD/verwerking/combine_2.csv
OLDIFS=$IFS
IFS=";"
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read productid productname deliveryid image url variantid ean1
sku price1 cost1 qty1 ean2 qty2 erp_supply_delay price2 cost2
do
echo \n"\nProductID=$productid Variant=$variantid sku=$sku Name=$productname stockLevel=$qty2 priceIncl=$price2 ean=$ean2 Delay=$erp_supply_delay"
if [ $COUNTVAR -eq '50' ]
then
echo "We have lift off!!"
#echo $VARIANTUPDATES
curl -g https://api.webshopapp.com/nl/variants/bulk.json -u "$KEY:$SECRET" -X "PUT" $VARIANTUPDATES
COUNTVAR=1
VARIANTUPDATES=""
else
VARIANTUPDATES="${VARIANTUPDATES}-d
\"variant[$COUNTVAR][id]=$variantid\" -d
\"variant[$COUNTVAR][stockLevel]=$qty2\" -d
\"variant[$COUNTVAR][priceIncl]=$price2\" -d
\"variant[$COUNTVAR][priceCost]=$cost2\" -d
\"variant[$COUNTVAR][unitPrice]=0\" -d
\"variant[$COUNTVAR][oldPriceIncl]=0\" -d
\"variant[$COUNTVAR][ean]=$ean2\" "
COUNTVAR=$((COUNTVAR+1))
echo $VARIANTUPDATES
fi
## Onderstaande is om minder updates te hebben
case $deliveryid in
$erp_supply_delay)
echo "SKU: " $sku " Levertijd OUD: " $deliveryid "
Levertijd NIEUW: " $erp_supply_delay " is hetzelfde. Wordt niet
geupdate."
;;
*)
echo "SKU: " $sku " Levertijd OUD: " $deliveryid "
Levertijd NIEUW: " $erp_supply_delay " is anders. Wordt geupdate"
curl -g https://api.webshopapp.com/nl/products/$productid.xml -u "$KEY:$SECRET" -X "PUT" -d product[deliverydate]=$erp_supply_delay
;;
esac
done < $INPUT
IFS=$OLDIFS
10 comments
the response that you're getting. If the call was successful, but the API didn't update any fields, you'll get this response:
You can also get errors if your response was well formatted, but Lightspeed can't make the updates for some reason. For example:
It could also be a problem with the quoting in your curl command. Getting the quotes right in shell scripts can be challenging. It's much easier in other languages like PHP or Python that have stricter syntax.
It may be easier in the long run to learn a bit of PHP or another language. You can build your request data as a native object (associative array, dictionary, etc.), then easily convert to JSON and sent it as the request body.
Lightspeed HQ
Lightspeed HQ
Stack trace:
#0 /srv/test/WebshopappApiClient.php(790): WebshopappApiClient->handleCurlError(Resource id #5)
#1 /srv/test/WebshopappApiClient.php(864): WebshopappApiClient->sendRequest('shop', 'get', Array)
#2 /srv/test/WebshopappApiClient.php(5404): WebshopappApiClient->read('shop')
#3 /srv/test/test.php(8): WebshopappApiResourceShop->get()
#4 {main}
thrown in /srv/test/WebshopappApiClient.php on line 840
You need to use the clustedid, in your case eu1.
Stack trace:
#0 /srv/lightspeed/test/WebshopappApiClient.php(790): WebshopappApiClient->handleCurlError(Resource id #5)
#1 /srv/lightspeed/test/WebshopappApiClient.php(864): WebshopappApiClient->sendRequest('shop', 'get', Array)
#2 /srv/lightspeed/test/WebshopappApiClient.php(5404): WebshopappApiClient->read('shop')
#3 /srv/lightspeed/test/test.php(8): WebshopappApiResourceShop->get()
#4 {main}
thrown in /srv/lightspeed/test/WebshopappApiClient.php on line 840
From the error, it looks like the cluster isn't correct.
Lightspeed HQ
After checking your error, it says api.webshopapp.net which should be api.webshopapp.com
Could you change this and try again?
Lightspeed HQ