gpt4 book ai didi

magento-1.7 - 我正在尝试发布数据,但我在 Magento REST API 上不断收到此错误 "code": 400, "message": "The request data is invalid."

转载 作者:行者123 更新时间:2023-12-02 21:51:54 26 4
gpt4 key购买 nike

我试图发布一些数据,然后调用 profPostAction 来检查 token ,但这个 _create 函数 根本不会被读取,并且错误请求无效不断出现,

protected function _create(array $data)
{
$action = $this->getRequest()->getParam('action') . 'PostAction';
if (method_exists($this, $action)) {
Mage::app()->setCurrentStore(1);
header("Content-type: application/json");
die(json_encode($this->$action($data)));
}

$this->_critical('Bad request.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
}

//尝试获取提供的 token 和数据以获取客户 ID

protected function profPostAction($data)
{
$token = $data['token'];
if (!$token) {
$this->_critical('Token is required.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
}

$_token = Mage::getModel('grouponapi/token')->load(mysql_escape_string($token), 'token');
if (!$_token->getId()) {
$this->_critical('Token is not valid!', Mage_Api2_Model_Server::HTTP_FORBIDDEN);
}

$customer_id = $_token->getCustomerId();
$_customer = Mage::getModel('customer/customer')->load($customer_id);
if (!$_customer->getId()) {
$this->_critical('Customer not found!', Mage_Api2_Model_Server::HTTP_NOT_FOUND);
}
}

最佳答案

确保您已为您尝试在 api2.xml 中创建的实体定义属性:

<attributes module="api2">
<entity_id>ID</entity_id>
<field1>Your Field 1</field1>
<field2>Your Field 2</field2>
</attributes>

关于magento-1.7 - 我正在尝试发布数据,但我在 Magento REST API 上不断收到此错误 "code": 400, "message": "The request data is invalid.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20786311/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com