1

ORIGINAL POST


Trying to use the save requisition list REST API endpoint. The API docs are not very clear on what the values should be and currently don't have access to the B2B module code to see what it exactly needs for the JSON input.

So, has anyone used this endpoint before? What would be a working example JSON? Am I even supposed to use this endpoint?

Doc link: https://devdocs.magento.com/redoc/2.3/async-admin-rest-api.html#operation/requisitionListRequisitionListRepositoryV1SavePost

Endpoint Example (POST method): https://magento-store.com/index.php/rest/V1/requisition_lists

Example of what I have used:

{
  "requisitionList": {
    "id": 0,
    "customer_id": 215120,
    "name": "My List A",
    "updated_at": "2019-05-06T15:49:00",
    "description": "None",
    "items": [
      {
        "id": 1,
        "sku": 20410320,
        "requisition_list_id": 0,
        "qty": 10,
        "options": [],
        "store_id": 1,
        "added_at": "2019-05-06T15:49:00",
        "extension_attributes": {}
      }
    ],
    "extension_attributes": {}
  }
}

Example Responses (2 of them):

{
    "message": "Could not save Requisition List"
}
{
    "message": "Internal Error. Details are available in Magento log file. Report ID: {error-id}"
}

UPDATE


It seems that not all the JSON fields are required as pointed out in the comments. I am now able to update an existing requisition list if I have the requisition list ID. I guess now does anyone know how to create a brand new list for a customer?

Request:

{
  "requisitionList": {
    "id":755,
    "customer_id": 215120,
    "name": "My List E",
    "items": [
      {
        "sku": 16740700,
        "qty": 3,
        "store_id": 1
      }
    ]
  }
}

Response:

{
    "id": 755,
    "customer_id": null,
    "name": "My List E",
    "updated_at": "1557246976",
    "description": null,
    "items": [
        {
            "id": 1316,
            "sku": "16740700",
            "requisition_list_id": 755,
            "qty": 3,
            "options": [],
            "store_id": 1,
            "added_at": null
        }
    ]
}
3
  • you can remove id since it has to be dynamically created then make sure you have store with store id 1
    – fmsthird
    May 6, 2019 at 21:48
  • @magefms Thanks, I will try that. I had it included in the JSON as the docs labeled it as required.
    – Henry Nitz
    May 7, 2019 at 16:28
  • 1
    @magefms That seemed to work for updating a list. I've updated the post. Any ideas/information on creating a new list for a customer? Thanks.
    – Henry Nitz
    May 7, 2019 at 16:41

1 Answer 1

0

seems like its overriding customer_id:

<parameter name="requisitionList.customer_id" force="true">%customer_id</parameter>

see: \Magento\Webapi\Controller\Rest\ParamOverriderCustomerId::getOverriddenValue

it will not work for admin rest api user, its only for end customers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.