Hey there! I'm facing an issue while trying to send a form to my Profile endpoint. The problem lies in the 'user:{}' field, as I am unable to properly insert my array data into this specific field.
Here is a breakdown of the fields within my endpoint:
{
"id": 4,
"ci": "123456",
"photo": "http://127.0.0.1:8000/media/profiles/12809632_10208569440535095_617453747387788113_n_zAUAVMf.jpg",
"phone_number": "+59177621589",
"user": {
"id": 5,
"username": "sdanderson",
"first_name": "ssss",
"last_name": "ssss"
},
"experience": "null",
"typeskill": [
{
"id": 1,
"skill_name": "developer"
}
]
}
Additionally, here is the service function that I have created for making a PUT request:
putProfile(id:string,token:string,body:any,files:any):Observable<Profile>{
//saving the data to be sent to the endpoint for updating
let formData: FormData = new FormData();
for (let file of files) {
formData.append('photo', file);
}
formData.append('ci',body['ci']);
formData.append('phone_number', body['phone_number']);
formData.append('experience',body['experience']);
formData.append('user',body['user']);//inside this field, I have: body['user'].id, body['user'].first_name, and body['user'].last_name
//add headers
let headers = new Headers();
headers.append('Accept', 'application/json');
headers.append("Authorization","Token "+ token);
return this.http.put(this.api+"profile/"+id+'/',formData,{headers})
.map(this.extractData)
.catch(this.handleError);
}