Delphix Products

 View Only
  • 1.  REST API to attach and email to a running job

    Posted 03-05-2020 06:29:00 PM
    Hi, 
         I can attach an email to a running job using CLI. 
        However, not understanding what my error is when using REST API. 

       Here is the code fragment 

       # Get job reference job_ref
     ​   ......

    # attach email to the job. It will automatically send email on job status
    # s is the session object. I am using request module 

    print (os.environ['EMAIL_GROUP'])
    payload = {
    "type":"Job",
    "emailAddresses":[os.environ['EMAIL_GROUP']]
    }
    rsp=s.post(endpoint + "job/" + job_ref, headers=headers,params=payload)
    print(rsp.url)
    print(rsp.text)


    ######################################

    Output as below:
    dbd.mathews@blueshieldca.com
    http://sac-delphix.bsc.bscal.com/resources/json/delphix/job/JOB-6364?emailAddresses=dbd.mathews%40blueshieldca.com&type=Job
    {"type":"ErrorResult","status":"ERROR","error":{"type":"APIError","details":"Missing required input of type \"Job\".","action":"Provide the input parameter and try again.","id":"exception.webservices.api.input.missing","commandOutput":null,"diagnoses":[]}}

    #############################################

    What am I doing wrong?
    ​​​

    ------------------------------
    Ansamma Mathews
    Community Member
    Blue Shield of California Life & Health Insurance Company
    ------------------------------


  • 2.  RE: REST API to attach and email to a running job

    Posted 03-06-2020 01:17:00 AM
    The problem seems to be that your code is sending the "payload" as query parameters while it must be sent in the POST body, so I believe you need to change

    params=payload
    to
    json=payload​


    ------------------------------
    Eyal Kaspi
    Staff Engineer
    Delphix Community Members
    ------------------------------



  • 3.  RE: REST API to attach and email to a running job

    Posted 03-06-2020 03:56:00 AM
    Hi Ansamma,

    Did you try to use "setopt trace=true" on the CLI console to check out the resulting API call made by th engie.

    It can help you dig into the heart of the issue.

    From the output it seems that there is some input missing for the job type.

    Regards,

    Mouhssine

    ------------------------------
    Mouhssine SAIDI
    Community Member
    Delphix Community Members
    ------------------------------