ActiveCampaign axios发布请求返回422

时间:2020-04-21 13:04:15

标签: javascript node.js axios http-status-code-422 activecampaign

这是对象和发布请求

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(final Stage primaryStage) {
        Label test = new Label();
        test.setText("Testing JavaFX........");
        VBox box = new VBox();
        ScrollPane pane = new ScrollPane(box);
        pane.setPrefSize(300.0, 300.0);
        box.getChildren().add(test);
        Scene main = new Scene(pane);
        primaryStage.setScene(main);
        primaryStage.show();
    }
}

这是我得到的答复

let contactObject = {
    contact: {
        email: "jsmith@example.com",
        firstName: "John",
        lastName: "Smith"
    }
};

const options = {
    method: 'POST',
    headers: {
        'Api-Token': `${token}`,
        'content-type': 'application/json',
    },
    data: contactObject,
    url,
};

await axios(options);

}

如果有人知道可能是什么问题,请帮助我尝试我能想到的一切。而且,无论如何更改数据对象或标头请求,我总是得到相同的响应。

这是ActiveCampaign API的链接

https://developers.activecampaign.com/reference#http-methods

1 个答案:

答案 0 :(得分:0)

在与ActiveCampaign的支持进行了交谈之后,我找到了解决方案,

const email = req.body.email;
const name = req.body.firstName;
const last = req.body.lastName;
const phone = req.body.phone;

let contactObject = {
    "contact": {
        "email": email,
        "firstName": name,
        "lastName": last,
        "phone": phone
    }
};