OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

odata message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: [OASIS Issue Tracker] (ODATA-1046) Add JSON format for Batch


    [ https://issues.oasis-open.org/browse/ODATA-1046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=65477#comment-65477 ] 

Michael Pizzo commented on ODATA-1046:
--------------------------------------

example json batch request:
POST /v1.0/$batch HTTP/1.1  

{
  batch1: {
    batchOptions: {
      ordering: "strict",
      onError: "terminate"
    },
    requests: [
      {
        id: "1",
        method: "post",
        url: "/users",
        headers: {
          "Content-Type": "application/json"
        },
        body: {
          displayName: "John Smith",
          userPrincipalName: "jsmith@contoso.com"
        }
      },
      {
        id: "2",
        method: "get",
        url: "$1/photo/$value",
        headers: {
          Accept: "image/jpeg"
        }
      }
    ]
  },
  batch2: {
    batchOptions: {
      ordering: "relaxed",
      onError: "continue",
      dependsOn: "batch1"
    },
    requests: [
      {
        id: "1",
        method: "get",
        url: "/groups?top=10",
        headers: {
          Accept: "application/json",
        }
      },
      {
        id: "2",
        method: "get",
        url: "/invalidEntity",
        headers: { 
          Accept: "application/json"
        }
      }
    ]
  },
  batch3: {
    batchOptions: {
      ordering: "relaxed",
      onError: "terminate"
    },
    requests: [
      {
        id: "1",
        method: "get",
        url: "/groups?top=10",
        headers: {
          Accept: "application/atom+xml",
        }
      }
    ]
  }
}

example batch response:

{
  batch1: {
    responses: [
      {
        id: "1",
        status: 201,
        headers: {
          Location: "/users/jsmith"
        }
      },
      {
        id: "2",
        status: 200,
        headers: {
          "Content-Type": "image/jpeg"
        },
        body: "FRwvAAIAAAANAA4AFAAhAPNTUAAAAAAAAAAAAAAQUAAAAAAADHrQX+"
      }
    ]
  },
  batch2: {
    responses: [
      {
        id: "1",
        status: 200,
        headers: {
          "Content-Type": "application/json"
        },
        body: {
          values: [
            {
              displayName: "user1"
            }
          ]
        }
      },
      {
        id: "2",
        status: 404,
        headers: {
          "Content-Type": "application/json"
        },
        body: {
          error: {
            message: "Resource Not Found."
          }
        }
      }
    ]
  },
  batch3: {
    responses: [
      {
        id: "3",
        status: 400
      }
    ]
  }
}


> Add JSON format for Batch
> -------------------------
>
>                 Key: ODATA-1046
>                 URL: https://issues.oasis-open.org/browse/ODATA-1046
>             Project: OASIS Open Data Protocol (OData) TC
>          Issue Type: Bug
>          Components: JSON Format
>    Affects Versions: V4.01_WD01
>         Environment: [Proposed]
>            Reporter: Michael Pizzo
>             Fix For: V4.01_CSD02
>
>
> Our batch request and response format today is multipart/mime.  We've had a lot of pushback from the beginning that this format is difficult to construct and parse; there are no off-the shelf tools or libraries for doing so.
> Now that we have a JSON format for CSDL, a JSON client no longer needs an XML parser to read CSDL, but they still have no way of expressing or consuming a batch without parsing the difficult to understand/complex multi-part mime.



--
This message was sent by Atlassian JIRA
(v6.2.2#6258)


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]