Edits history of script submission #22761 for ' Update Prospect (outreach)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Update Prospect
     * Updates attributes of an existing prospect (e.g. { "title": "VP Sales", "occupation": "Sales" }).
     */
    export async function main(
      auth: RT.Outreach,
      prospect_id: number,
      attributes: { [key: string]: any }
    ) {
      const response = await fetch(
        `https://api.outreach.io/api/v2/prospects/${prospect_id}`,
        {
          method: "PATCH",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/vnd.api+json",
            Accept: "application/vnd.api+json",
          },
          body: JSON.stringify({
            data: { type: "prospect", id: prospect_id, attributes },
          }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 hours ago