POST 请求适用于 Postman,但不适用于 Angular 11

问题描述

我有一个 ping Django 后端的 HTTP post 请求。当从 Postman 发出请求时,我能够得到有效的响应。但是从 Chrome 触发,使用语义相同的 json 负载,我收到 400 错误请求。

Image of the Services

Post man example

以下是我使用的 json 模型,以 angular 构建主体。

标题保持不变,授权也完全相同(使用基本身份验证)。我唯一能想到的问题是 CORS,但是,我正在代理它来解决这个问题。

export class RealResult {
  node: string;
  source: string;
  destination: string;
  protocol: string;
  source_port: string;
  destination_port: string;
  direction: string;
  acl_ID: string;
  zone: string;
  action: string;
  timestamp: string;
  flowID: string;

  constructor(data: RealResult) {
    this.node = data.node;
    this.source = data.source;
    this.destination = data.destination;
    this.protocol = data.protocol;
    this.source_port = data.source_port;
    this.destination_port = data.destination_port;
    this.direction = data.direction;
    this.acl_ID = data.acl_ID;
    this.zone = data.zone;
    this.action = data.action;
    this.timestamp = data.timestamp;
    this.flowID = data.flowID
  }
}

export class Success {
  results: Result[];

  constructor() {
    this.results = []
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...