#POST request with skript

1 messages · Page 1 of 1 (latest)

spice quarry
#
    trigger:
        set {_name} to arg-1
        set {_ticker} to arg-2
        set {_description} to arg-3
        set {_imageUrl} to arg-4

        set {_json} to "{\"name\": \"%{_name}%\", \"ticker\": \"%{_ticker}%\", \"description\": \"%{_description}%\", \"image_url\": \"%{_imageUrl}%\"}"
        set {_request} to http request
        set {_request} to new http request with method "POST"
        set {_request}'s target url to "<test>
"
        set {_request}'s header "Content-Type" to "application/json"
        set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.2"
        set {_request}'s body to {_json}
        send async web request with {_request}

        on web request response:
            set {_response} to event-response
            if {_response}.code is 200:
                send "Coin creation request sent successfully! Response: %{_response}.body%" to player
            else:
                send "Failed to create coin. Response code: %{_response}.code% - Response: %{_response}.body%" to player```