Download Function Code

Purpose

This API downloads the source code of the specified function.

  • Deluge Functions: A Deluge function consists of a single source file containing the function logic. When downloaded, the API returns the function as a .ds file with a maximum file size of 2 MB.
  • Multi-file runtime Functions: Java, Node.js, and Python
    Each function is packaged as a project that can contain multiple source files and folders, rather than a single source file. When downloaded, the API returns the function as a ZIP (.zip) package with a maximum file size of 25 MB.

Endpoints

  • GET /settings/functions/{function_identifier}/code

Here, {function_identifier} represents the unique ID or API name of the Function. You can obtain the Function ID or API name using the List Functions API.

Request Details

Request URL

{api-domain}/crm/{version}/settings/functions/{function_identifier}/code 


Here, {function_identifier} represents the unique ID or API name of the function. You can obtain the function ID or API name using the List Functions API.

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

ZohoCRM.settings.functions.READ
(or)
ZohoCRM.settings.functions.ALL
(or)
ZohoCRM.settings.ALL

Parameters

  • versionstring, optional

    Specifies the version of the function code to download.

    Possible values: 

    draft - Downloads the draft version of Java, Node.js, and Python function.
    Note: 

    • This parameter is applicable only to Java, Node.js, and Python function. If omitted, the API downloads the published version.
    • If you specify a value other than draft, the system returns the PATTERN_NOT_MATCHED error.
       

Sample Request

Copiedcurl"https://www.zohoapis.com/crm/v8/settings/functions/5725767000010649399/code"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"

Sample Responses

Deluge (.ds)

deluge 
 

Multi-line Runtimes - Java Function ZIP(.zip)

deluge

Note

The above images show sample downloads for both Deluge functions and multi-file runtime functions (Java, Node.js, and Python).

Possible Errors

  • INVALID_DATAHTTP 400

    Invalid function ID
    Resolution: You have specified an invalid function ID or API name. Specify a valid function ID or API name. Use the list of Functions to retrieve the details.

  • CANNOT_PERFORM_ACTIONHTTP 400
    • Draft does not exist in the specified function
      Resolution: Ensure that the specified function has a draft version before setting the version parameter to draft. The draft version is supported only for Java, Node.js, and Python functions. Use the List Functions API to retrieve the function ID and check whether the has_draft field is true ("has_draft": true).
    • Published version does not exist
      Resolution: Publish the function before attempting to download its code, and then retry the request.
  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to the Endpoints section for more details.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: The client does not have a valid scope to download the function. Create a new token with valid scope. Refer to the Scope section for more details.

  • AUTHENTICATION_FAILUREHTTP 401

    Authentication failed
    Resolution: Pass the access token in the request header of the API call.

  • NO_PERMISSIONHTTP 403

    Permission denied.
    Resolution: The user does not have permission to publish the specified function. Contact your Zoho CRM administrator to obtain the required permissions.

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to the Request URL section for more details.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in the server. Contact support team.