YUIKJOO Posted July 28, 2021 Posted July 28, 2021 (edited) Here's my applescript. tell application "Finder" set fullname to name of (selection as alias) set AppleScript's text item delimiters to {"_"} set Cname to first text item of fullname set Cmobile to second text item of fullname set Ccustomer to second text item of fullname display dialog ("이름: " & Cname & " 전화번호: " & Cmobile & " 고객번호: " & Ccustomer) do shell script "Cname=" & Cname & " Cmobile=" & Cmobile & " Ccustomer=" & Ccustomer & "; curl --location --request POST 'https://api.loyverse.com/v1.0/customers' --header 'Content-Type: application/json;charset=UTF-8' --header 'Authorization: Bearer d911043####################' --header 'Cookie: AWSALB=327XFY8AKfJFItTfErSMIf2R+cKJfgQeedICFa0WH5yC6qVfsZL5Rhxb+S2DBmdx0lmLIBquXdSVrB0yfMMQ00z6tH9imVXEzF6VZ8a993Kze1AkeH9grq######; AWSALBCORS=327XFY8AKfJFItTfErSMIf2R+cKJfgQeedICFa0WH5yC6qVfsZL5Rhxb+S2DBmdx0lmLIBquXdSVrB0yfMMQ00z6tH9imVXEzF6VZ8a993Kze1AkeH9grq######' --data-raw '{ \"name\": '$Cname', \"phone_number\": '$Cmobile', \"customer_code\": '$Ccustomer', \"note\": \"\"}'" --do shell script "Cname=" & Cname & " Cmobile=" & Cmobile & " Ccustomer=" & Ccustomer & "; echo $Cname $Cmobile $Ccustomer" end tell Cname is 홍길동 Cmobile is 01000000000 Ccustomer is 01000000000 By doing this, I can register customers to loyverse from Finder by based on filename. But it gets error regarding""{\"errors\":[{\"code\":\"BAD_REQUEST\",\"details\":\"Invalid UTF-8 start byte 0x84 (line 1 character 16)\"}]}"" When I echo it to see if variable works, it shows find. Where should I fix? Edited July 28, 2021 by YUIKJOO to remove token
Jay Rock Posted July 28, 2021 Posted July 28, 2021 Hello, looks like you send json with invalid character not supported by json format
Recommended Posts