Update 1 field of multiple contents squidex API

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x] Documentation issue or request

Current behavior

I want to Update 1 field of multiple contents squidex API and I search and I found it in [IMPLEMENTED] Bulk multiple contents update , but It return to Validation error. It’s my code



And here is my schemas

Expected behavior

Minimal reproduction of the problem

Environment

App Name:

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x] Cloud version

Version: [VERSION]

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [x] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Can you send me the actual JSON?

Besides that, this is not how the BULK endpoint works. It only updates one content at a time for each job.

is it right ?

I mean the json of your request.

is it right ?
{
"total": 2,
"items": [
    {
        "id": "fc4e8c50-3716-4614-8220-5b47f9072a7e",
        "createdBy": "subject:6176843dab5e35b2da25c899",
        "lastModifiedBy": "client:test06:default",
        "data": {
            "title": {
                "iv": "donggon"
            },
            "status": {
                "iv": "udoo"
            },
            "content": {
                "iv": "udoo"
            }
        },
        "created": "2021-11-25T02:27:40Z",
        "lastModified": "2021-12-08T05:41:05Z",
        "status": "Published",
        "statusColor": "#4bb958",
        "schemaId": "da721bb0-7b3f-4376-9809-d7f4930ba93f",
        "schemaName": "post",
        "schemaDisplayName": "post",
        "isDeleted": false,
        "version": 14,
        "_links": {
            "self": {
                "href": "/api/content/test06/post/fc4e8c50-3716-4614-8220-5b47f9072a7e",
                "method": "GET"
            },
            "previous": {
                "href": "/api/content/test06/post/fc4e8c50-3716-4614-8220-5b47f9072a7e/13",
                "method": "GET"
            },
            "draft/create": {
                "href": "/api/content/test06/post/fc4e8c50-3716-4614-8220-5b47f9072a7e/draft",
                "method": "POST"
            },
            "delete": {
                "href": "/api/content/test06/post/fc4e8c50-3716-4614-8220-5b47f9072a7e",
                "method": "DELETE"
            }
        }
    },
    {
        "id": "cb7c68b1-50d7-42c9-a6ee-7e969cca84bf",
        "createdBy": "client:test06:default",
        "lastModifiedBy": "subject:6176843dab5e35b2da25c899",
        "data": {
            "title": {
                "iv": "tất cả chỉ là các bụi sao trời"
            },
            "status": {
                "iv": "publish"
            },
            "content": {
                "iv": "This is my first post created using rest API"
            }
        },
        "created": "2021-11-22T15:19:33Z",
        "lastModified": "2021-11-25T02:27:25Z",
        "status": "Published",
        "statusColor": "#4bb958",
        "schemaId": "da721bb0-7b3f-4376-9809-d7f4930ba93f",
        "schemaName": "post",
        "schemaDisplayName": "post",
        "isDeleted": false,
        "version": 1,
        "_links": {
            "self": {
                "href": "/api/content/test06/post/cb7c68b1-50d7-42c9-a6ee-7e969cca84bf",
                "method": "GET"
            },
            "previous": {
                "href": "/api/content/test06/post/cb7c68b1-50d7-42c9-a6ee-7e969cca84bf/0",
                "method": "GET"
            },
            "draft/create": {
                "href": "/api/content/test06/post/cb7c68b1-50d7-42c9-a6ee-7e969cca84bf/draft",
                "method": "POST"
            },
            "delete": {
                "href": "/api/content/test06/post/cb7c68b1-50d7-42c9-a6ee-7e969cca84bf",
                "method": "DELETE"
            }
        }
    }
],
"statuses": [
    {
        "status": "Archived",
        "color": "#eb3142"
    },
    {
        "status": "Draft",
        "color": "#8091a5"
    },
    {
        "status": "Published",
        "color": "#4bb958"
    }
],
"_links": {
    "self": {
        "href": "/api/content/test06/post",
        "method": "GET"
    },
    "create": {
        "href": "/api/content/test06/post",
        "method": "POST"
    },
    "create/publish": {
        "href": "/api/content/test06/post?publish=True",
        "method": "POST"
    }
}
}

I mean the json of the request you sent to the squidex API. The body of the request. not the response.

The body here 
 const data = {
      post: [
        {
          type: "Patch",
          query: {
            filter: {
              path: "data.status.iv",
              op: "eq",
              value: "udoo",
            },
          },
          expectedCount: 123,
          data: {
            name: {
              iv: "donggon",
            },
          },
        },
      ],
    };

I need the actual JSON, not the javascript structure.

{
    "title": {
        "iv":"donggon"
    },
    "status": {
        "iv":"publish"
    },
    "content": {
        "iv":"first content"
    }
}

In the previous post you have sent me something with

The body here 
 const data = { 
   post: [
   ]

This is a javascript structure that is somehow serialized to JSON and then sent to Squidex over the wire. I need this JSON structure.

The result of your JSON.stringify(data)

is it right ?
    {
      "post": [
        {
          "type": "Patch",
          "query": {
            "filter": {
              "path": "data.status.iv",
              "op": "eq",
              "value": "udoo"
            }
          },
          "expectedCount": 123,
          "data": {
            "title": {
              "iv": "donggon"
            }
          }
        }
      ]
    }

Yes, where do you have this extra "post": [ thing from: it needs to be jobs.

{
      "jobs": [
        {
          "type": "Patch",
          "query": {
            "filter": {
              "path": "data.status.iv",
              "op": "eq",
              "value": "udoo"
            }
          },
          "expectedCount": 123,
          "data": {
            "title": {
              "iv": "donggon"
            }
          }
        }
      ]
    }

I think “jobs” mean schemas, so I change jobs to post, but when I change to jobs, it still wrong

You also use the wrong URL, should be

https://cloud.squidex.io/api/content/<APP-NAME>/<SCHEMA-NAME>/bulk

I tried and it return to 404 status code
Screen Shot 2021-12-08 at 19.50.38

This is good, perhaps your query does not work or returns more than one value?

I remove type:“Patch” and it work, but it create new post instead of update field I filtered


Screen Shot 2021-12-08 at 20.27.31

Yes, because the default action is “Upsert” Update or Insert.

How I change to Patch ? Because I want to update 1 filed for all content, If I insert type:“Patch”, it’s fail

Are you sure that your filter works? Have you verified it in the UI? If you know the ID you can also use the id instead of the query.