# Update Profile Picture PUT /api/v1/iam/user/profile-picture/ Content-Type: multipart/form-data Updates the profile picture for the authenticated user. Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/iam/user-profile-picture-update ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v1/iam/user/profile-picture/: put: operationId: user-profile-picture-update summary: Update Profile Picture description: Updates the profile picture for the authenticated user. tags: - subpackage_iam responses: '200': description: Profile picture updated successfully content: application/json: schema: description: Any type '400': description: Invalid input content: application/json: schema: description: Any type '401': description: Unauthorized content: application/json: schema: description: Any type requestBody: content: multipart/form-data: schema: type: object properties: profile_picture: type: string format: binary description: The profile picture file ``` ## SDK Code Examples ```python Profile Picture Update Example import requests url = "https://api.example.com/api/v1/iam/user/profile-picture/" files = { "profile_picture": "open('', 'rb')" } response = requests.put(url, files=files) print(response.json()) ``` ```javascript Profile Picture Update Example const url = 'https://api.example.com/api/v1/iam/user/profile-picture/'; const form = new FormData(); form.append('profile_picture', ''); const options = {method: 'PUT'}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Profile Picture Update Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/iam/user/profile-picture/" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"profile_picture\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("PUT", url, payload) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Profile Picture Update Example require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/iam/user/profile-picture/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"profile_picture\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java Profile Picture Update Example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.example.com/api/v1/iam/user/profile-picture/") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"profile_picture\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php Profile Picture Update Example request('PUT', 'https://api.example.com/api/v1/iam/user/profile-picture/', [ 'multipart' => [ [ 'name' => 'profile_picture', 'filename' => '', 'contents' => null ] ] ]); echo $response->getBody(); ``` ```csharp Profile Picture Update Example using RestSharp; var client = new RestClient("https://api.example.com/api/v1/iam/user/profile-picture/"); var request = new RestRequest(Method.PUT); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"profile_picture\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Profile Picture Update Example import Foundation let parameters = [ [ "name": "profile_picture", "fileName": "" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/iam/user/profile-picture/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```