Table of contents

    Overview

    A Document endpoint is used to upload files to MYP. To call this endpoint, use one of the URLs from the following table:

    URL GET PUT POST DELETE
    https://api.mypcorp.com/document
    https://api.mypcorp.com/document/{DocumentGuid}
    https://api.mypcorp.com/document/{DocumentGuid}/Download

    Get

    The following table illustrates which fields can be included when receiving a GET response.

    NB: Nested properties are hidden by default. To expand all nested properties, add a query parameter $expand=* to the URL.

    Document
    Field Name Description
    DocumentGuid
    Guid (Identifier)
    Document id.
    DocumentName
    string
    Name of the document.
    ClientGuid
    Guid
    Guid of Client under which this document was uploaded.
    CreationDate
    datetime
    Date and time when this document was created.
    ArchiveDate
    DateTime
    Date when the document was archived, if it has been archived.
    DocumentCategory
    object
    A list of DocumentCategory.

    Example JSON format:

    {
      "@odata.context": "https://api.mypcorp.com/document/$metadata#Document(DocumentCategory())",
      "value": [
        {
          "DocumentGuid": "119ae644-5045-4fd2-975a-384bcb3f0161",
          "DocumentName": "Invoice.pdf",
          "ClientGuid": "cb8dc5dd-532b-4e74-98f1-5ad28d72f042",
          "CreationDate": "2021-05-11T10:28:47.53+10:00",
          "ArchiveDate": null,
          "DocumentCategory": {
            "DocumentCategoryGuid": "d79f724c-f2d8-4f94-9f06-d53bbd6adea8",
            "Name": "Photography",
            "ArchiveDate": null
          }
        }
      ]
    }

    Post

    A list of documents can be uploaded to MYP API. To upload documents, set the body of the POST request to form-data and add the file in the form-data.

    The following table illustrates which fields can be included when sending a POST request:

    Form-Data
    Field Name Description Required
    Files
    File
    A list of files, or 1 file to upload. Required
    CreatedByStaffGuidList
    Guid
    A list of Staff guids who uploaded each document. The number of staff guids must match the number of files to upload. Required
    DocumentCategoryGuidList
    Guid
    A list of DocumentCategory guids. The number of category guids must match the number of files to upload. Required
    ClientGuidList
    Guid
    A list of Client guids under which each document was uploaded. If this list is not null, then the number of client guids must match the number of files to upload, however some of those client guids can be null. Optional
    Names
    string (256)
    A list of names for the uploaded files. If not omitted, the number of names must match the number of files to upload. Optional

    NB: The order of files matches the order of DocumentCategoryGuidList and Names. For example, the 2nd category guid is used for the 2nd file.

    NB: To get Guids for document categories, call the DocumentCategory endpoint.

    Download

    To download a document, send a GET request containing the document GUID in the request URL:

    GET: https://api.mypcorp.com/document/{DocumentGuid}/download

    Response

    If the document is found, the endpoint returns a 200 Ok response with the document file as bytes.

    If a document matching the supplied GUID is not found, the endpoint returns a 404 Not Found response.


    Previous article Next article