Here is an example of how to make a POST request to Azure Storage REST API using Swift 5:
let urlString = "<YOUR_STORAGE_URL>"
let url = URL(string: urlString)!
let request = NSMutableURLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
// Set the body of the request
let body = // Your JSON body
request.httpBody = try? JSONSerialization.data(withJSONObject: body, options: [])
// Set the Authorization header with a shared access signature (SAS) token
let sas = "<YOUR_SAS_TOKEN>"
request.setValue(sas, forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: request as URLRequest) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data {
// Process the response data
}
}
task.resume()
Note that you will need to replace <YOUR_STORAGE_URL>
with the URL for your Azure Storage account and <YOUR_SAS_TOKEN>
with a shared access signature token that provides access to the resource you want to operate on (e.g., a container, blob, or queue).
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-07-31 11:00:00 +0000
Seen: 12 times
Last updated: Jun 24 '22
What is the process for installing SASS/Compass in the DDEV web container?
What is the best way to arrange the file structure for both the backend and frontend in MERN?
What is the method of merging several inline style objects?
Is it possible to utilize a SAS Server for storing network files? If so, what is the process?
What is the method of including a list of macro variables as a column in a SAS dataset?
What is a data storage solution for backing up data?
What is the process of creating critical notifications in iOS using Expo SDK 42 managed?