Hey I'm using Directus with Ionic 3 for browser and I got a problem with HTTP PUT.
The error:
error: {code: 6, message: "Method Not Allowed"}
proto: Object
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure response for http://example.com/backend/api/public/_/users?single=1&access_token=myToken&filter[id]=50: 405 Method Not Allowed"
name: "HttpErrorResponse"
ok: false
status: 405
statusText: "Method Not Allowed"
url: "http://example.com/backend/api/public/_/users?single=1&access_token=myToken&filter[id]=50"
This my code:
updatePwd(user:any, userId: any){
return this.api.put('users?single=1&access_token=myToken&filter[id]='+userId,user).map((res: any) => {
return res;
});
}
The POST and GET work good like that
newUser(user:any){
return this.api.post('users?access_token=myToken',user).map((res: any) => {
return res;
});
}
getUser(email:any){
return this.api.get('users?single=1&access_token=myToken&filter[email]='+email).map((res: any) => {
return res;
});
}
I'm new user of Directus and I don't know much about it. So what the problem here? I must config something or what?
Thanks in advance :)
Edit: I tried with PATCH and It works fine ^^
updatePwd(userId: any, user:any){
return this.api.patch('users/'+userId+'?&access_token=myToken',user).map((res: any) => {
return res;
});
}
Directus uses PATCH instead of PUT for updating rows: https://docs.directus.io/api/reference.html#update-user