How to pass Array values in Postman

Asked

Viewed 2,791 times

-1

I am developing an API, and one of the modules is the ACL(access control list) in the Laravel Framework.

I came to a problem that I haven’t found plausible solutions yet, which is like testing values that get more than one parameter in it.

In my case I’m creating Roles and in those Roles, the moment I go to create them, I need to pass the Permissions that she will own on Postman. In the current scenario I can only link to a Permission.

I used these examples like this:

campo [1, 2, 3] campo {1, 2, 3} array[campo] 1,2,3

I want to register n permissions for that new Rule`.

criando uma role com uma unica permission

  • 2

    Calls the field of permissions[], square brackets and replay the field as often as you like, similar to PHP’s own syntax to add the value to the array.

  • within each permissions[] will be a new field that will have a id, more or less that?

2 answers

1

Don’t just send an array? Is your question about syntax? Use something like:

{
    "data": {
        "id": 49,
        "name": "Role 644",
        "label": "Role 453",
        "description": "Descrição da Role 258",
        "permissions": [{
            "id": 1,
            "name": "create_permission",
            "label": "Criar permissão",
            "created_at": null,
            "updated_at": null,
            "pivot": {
                "role_id": 49,
                "permission_id": 1
            }
        },{
            "id": 2,
            "name": "edit_permission",
            "label": "Editar permissão",
            "created_at": null,
            "updated_at": null,
            "pivot": {
                "role_id": 50,
                "permission_id": 2
            }
        }]
    }
}

0


Passing a campo[] but the values for each field you need, in my case the permissions.

solução

  • That’s an answer?

  • Yes. Pass the field Permissions[] how many times the field needs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.