The CreatorCon Call for Content is officially open! Get started here.

How to send csv file to snow in original format (no binary & no base64) and attach it using RESTapi

Obito
Tera Expert

Hi All,

How to send csv file to snow in original format (no binary & no base64) using REST API and attach it to particular record. and is this even possible to send csv file over api in original format. Please suggest. 

 

@Ankur Bawiskar  Please share your suggestion.

 

Thank you.

1 ACCEPTED SOLUTION

Ratnakar7
Mega Sage

Hi @Obito ,

 

You can do so by attaching the CSV file to a record in ServiceNow. Here are the general steps:

  1. Upload CSV to a Secure Location: First, upload the CSV file to a secure location accessible via a URL. This could be on your server, a cloud storage service, or any location with a publicly accessible URL.

  2. Create a ServiceNow Record: Create a new record or update an existing record in ServiceNow that you want to associate with this CSV file. Ensure that this record has a field where you can store the URL of the CSV file.

  3. Use REST API to Update the Record: Use the ServiceNow REST API to update the record created in step 2. In the request, include the URL of the CSV file, not the CSV file itself.

Here's an example of how you might structure your REST API request using a tool like cURL:

curl -X PUT \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YOUR_AUTH_TOKEN" \
  -d '{
    "csv_url": "https://your-csv-storage.com/path/to/your.csv"
  }' \
  "https://your-instance.service-now.com/api/now/table/your_table/YOUR_RECORD_SYS_ID"

 

Thanks,

Ratnakar

View solution in original post

2 REPLIES 2

Ratnakar7
Mega Sage

Hi @Obito ,

 

You can do so by attaching the CSV file to a record in ServiceNow. Here are the general steps:

  1. Upload CSV to a Secure Location: First, upload the CSV file to a secure location accessible via a URL. This could be on your server, a cloud storage service, or any location with a publicly accessible URL.

  2. Create a ServiceNow Record: Create a new record or update an existing record in ServiceNow that you want to associate with this CSV file. Ensure that this record has a field where you can store the URL of the CSV file.

  3. Use REST API to Update the Record: Use the ServiceNow REST API to update the record created in step 2. In the request, include the URL of the CSV file, not the CSV file itself.

Here's an example of how you might structure your REST API request using a tool like cURL:

curl -X PUT \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YOUR_AUTH_TOKEN" \
  -d '{
    "csv_url": "https://your-csv-storage.com/path/to/your.csv"
  }' \
  "https://your-instance.service-now.com/api/now/table/your_table/YOUR_RECORD_SYS_ID"

 

Thanks,

Ratnakar

Hi Ratnakar, 

I am using Basic auth with some username and password so how can i update the above script. 

Thank you