我需要在我的angular和django项目上得到帮助,当我发出一个post请求时,我得到一个400坏的响应错误,项目的工作流程如下,用户注册(成功),然后被重定向到一个profile form,然后当我尝试在填写profile后发出post请求时,我得到一个400err,以下是我的代码和err响应。
addProfile(profile: Iprofile): Observable<Iprofile>{
const url = 'http://127.0.0.1:8000/user/profiles';
return this.httpClient.post<Iprofile>(url, profile)
.pipe(
map(response => response),
catchError(this.handleError)
);
}
addUpdateProfile(){
if (this.profile) {
this.dataService.updateProfile(this.profileForm.value)
.subscribe(item => this.profiles.push(this.profileForm.value));
}
else {
this.dataService.addProfile(this.profileForm.value)
.subscribe(item => this.profiles.push(this.profileForm.value));
}
}
path('profiles', CreateProfileView.as_view(), name='user-profile'),
class CreateProfileView(generics.ListCreateAPIView):
queryset = Profile.objects.all()
serializer_class = UserDetailSerializer
坏的请求:userprofiles[14May2020 17:07:04]"POST userprofiles HTTP1.1" 400 46。
如果有人能帮助我,我将很高兴