I am able to perform a get request to retrieve SQL scripts within our workspace as mentioned in the docs: Sql Script - Get Sql Scripts By Workspace
%%pyspark
import requests
token = mssparkutils.credentials.getToken('Synapse')
# api-endpoint voor get requests
url = "https://xxxx-xx-xx-xxx-xx-xxx-xx.dev.azuresynapse.net/sqlScripts?api-version=2020-12-01"
headers = {'Authorization': f"Bearer {token}"}
response = requests.get(url, headers=headers)
However, I also want to be able to create new sql script using the same method, but instead performing a PUT request as mentioned here: Sql Script - Create Or Update Sql Script
#instead of request.get now using put
requests.put(url2, data=data, headers=headers2)
I am getting a '202 Accepted' response, meaning the response was accepted. Unfortunately no new scripts are created in our workspace. The response state does say "state":"Creating","created"...
What am I doing wrong?
This is an example of the response output:
b'{"id":"/subscriptions/xxxx-xx-xxx-xxx-xxxx/resourceGroups/xxx-xx-xxx-xxx-xx/providers/Microsoft.Synapse/workspaces/xxx-xx-xx-xxx-xx-xxxx-xxx/sqlScripts/test","recordId":xxxx,"state":"Creating","created":"2023-10-12T15:40:03.6666667Z","changed":"2023-10-12T15:40:03.6666667Z","type":"SqlScript","name":"test","operationId":"xxxxxx-xxx-xxx-xxxx-xxxxxx","artifactId":"xxxxx-xxxxx-xxxx-xxx-xxxxxxxx"}' <Response [202]>

