Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 在angular post请求中收到400个错误请求我如何修复此问题_Django_Angular_Django Rest Framework - Fatal编程技术网

Django 在angular post请求中收到400个错误请求我如何修复此问题

Django 在angular post请求中收到400个错误请求我如何修复此问题,django,angular,django-rest-framework,Django,Angular,Django Rest Framework,请我需要angular和django项目的帮助,当我发出post请求时,我收到400个错误响应,项目工作流程如下,用户注册成功,然后被重定向到配置文件表单,然后当我在填写配置文件后尝试发出post请求时,我收到400个错误,下面是我的代码和d错误响应 角度服务 django URL django视图 错误反应 错误请求:/user/profiles [14/May/2020 17:07:04]POST/user/profiles HTTP/1.1400 46 如果有人能帮助我,我会很高兴。如果为

请我需要angular和django项目的帮助,当我发出post请求时,我收到400个错误响应,项目工作流程如下,用户注册成功,然后被重定向到配置文件表单,然后当我在填写配置文件后尝试发出post请求时,我收到400个错误,下面是我的代码和d错误响应

角度服务 django URL django视图 错误反应 错误请求:/user/profiles [14/May/2020 17:07:04]POST/user/profiles HTTP/1.1400 46

如果有人能帮助我,我会很高兴。如果为创建对象提供的请求数据无效,将返回400错误请求响应,错误详细信息作为响应主体。因此,您发送的配置文件无效。若要查看哪个部分出错,请记录正文,或者您可以重写并调试的post方法

    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