Automation of Object schema export

Artem Dosuzhin March 15, 2018

Is it possible to automate export of some object type tables in csv, for example - after updating information in one object?

 

Or is it possible to make export of some object type in csv, for example, once per hour?

2 comments

Alexander Sundström
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2018

Hi Artem,

Object Type

It's not possible to schedule an export in Insight, but we have an open API that could be used so that you can create something on your own, as there is a an end-point to do Bulk Export for object types. 

Method is GET, the endpoint is 

/rest/insight/1.0/objecttype/{id}/export and the returned type is a binary type i.e. a csv file named export.csv. The query parameters are:

  • searchParams: "{"iqlSearch":true,"iqlParams":{"objectTypeId":"{

id}","attributesToDisplay":{"attributesToDisplayIds":["12", "34"]},"page":1,"asc":1,"resultsPerPage":25,"includeAttributes":false,"objectSchemaId":"{

id}","iql":""},"objectSchemaId":"{

id}"}"

  • delimiterValue COLON or other allowed delimiters
  • charEncoder UTF-8 or other supported encoding
  • importable 0 for User Friendly and 1 for Data Consistent.

Also be aware that the parameters in searchParams needs to replaved with your own parameters and if you have more that 25 objects just place that number.

Schema

There isn't any built in support to do this, but I can give you the information about the REST-API call used to create an Export, and that way you could trigger this manually on a scheduled basis.

URL: rest/insight/1.0/objectschema/export/server

Method: Post

Parameters:

The provided JSON needs the following parameters:

  • String fileName (ie schema.zip) (MANDATORY)
  • Integer objectSchemaId (MANDATORY)
  • String objectSchemaName (MANDATORY )
  • String password (OPTIONAL)
  • Boolean includeObjects (OPTIONAL)
  • Integer totalObjectsInExport (Shouldn't be needed)

This will export it to the server at export/insight in the home directory. You could then optionally copy this export and move it somewhere else.

If you need help on creating such a script, you could get in contact with one of out partners. Riada Partners extends the value of our products. If you need a plugin on top of Insight, a migration done, product training, support with a license purchase or help with setup and config, we’ve got the partner for the job. For more information, take a look at https://riada.se/partners/

 

If you feel like this answered your question, please mark it as accepted :)

 

Cheers!
Alexander

Like László Kiss likes this
Artem Dosuzhin April 9, 2018

Hi, Alexander!

I tried to use GET Method: http://sd.dev.fxclub.org:8080/rest/insight/1.0/objecttype/798/export , where 798 is ID of objecttype PC/Laptop in my ObjectSchema, but i have received error(500 Internal Server Error). Code of error can be seen here: https://pastebin.com/gASM5fzn.

Can you help me?

Alexander Sundström
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2018

Hi Artem,

You are missing parameters on the URL,

I have attached an example from using restlet client that you can use to build up the query parameters. They are mentioned earlier in this questions.

Screen Shot 2018-04-10 at 14.39.22.png

Basically you are missing the following section  after 798/export in the URL (which of course needs adjustment to your instance:

?searchParams={"iqlSearch":true,"iqlParams":{"objectTypeId":"{1} ","attributesToDisplay":{"attributesToDisplayIds":[ 3587,3593,3594,3598,3603]},"page":1,"asc":1,"resultsPerPage":25,"includeAttributes":false,"objectSchemaId":"{9}","iql":""},"objectSchemaId":"{9}"}&delimiterValue=COLON&charEncoder=UTF8&importable=1

MarieClaire Fnk July 15, 2020

We were using the rest/insight/1.0/objectschema/export/server endpoint to schedule an automatic export however once we upgraded to version 8.6 this stopped working - status code is 403. 

Has this been intentionally removed or has the url changed?

Badr Nazzal August 14, 2020

Does the export endpoint still exist in version 8.6?

I just get "Something went wrong. Contact administrator"

MarieClaire Fnk August 14, 2020

The endpoint has recently been changed to: 

/rest/insight/1.0/objectschemaexport/export/server

Badr Nazzal August 14, 2020

with POST /rest/insight/1.0/objectschemaexport/export/server I get status code 404. 

what about GET /rest/insight/1.0/objecttype/{id}/export ? has that changed? and are these changes documented?

Like Grzegorz likes this
László Kiss March 25, 2024

Hello Atlassian Community,

 

The endpoint /rest/insight/1.0/objectschemaexport/export/server worked for me.

Is it possible to specify in the POST body that only certain columns be included in the export?

 

Best regards,

Laszlo

TerAnYu June 9, 2019

Hello!
My script for backup:

https://github.com/TerAnYu/jira/blob/master/insight_backup.sh

need command-line JSON processor: https://stedolan.github.io/jq/

The actual version is only on the github!

#!/bin/sh
# version: 20190611
# Writer: TerAnYu
# need: command-line JSON processor
# wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O jq && chmod +x jq
# curl with libssl

url=http://127.0.0.1:8080
listreq=/rest/insight/1.0/objectschema/list
exportreq=/rest/insight/1.0/objectschema/export/server
username="localuser"
password="localpassword"
archpwd=123456
date=`date +"%Y%m%d_%H%M%S"`


data=`curl -s \
--connect-timeout 5 \
-u "${username}":"${password}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X GET ${url}${listreq}`
    ids=`echo ${data} | ./jq -r '.objectschemas[].id'`
    cnt=0

for i in $ids; do
    name=`echo ${data} | ./jq -r ".objectschemas[${cnt}].name"`
    countobj=`echo ${data} | ./jq -r ".objectschemas[${cnt}].objectCount"`
# echo output: "${cnt}; ${date}; ${i}; ${name}; ${countobj}"
   cnt=$((cnt+1))


param(){
  cat <<EOF
{
"fileName":"${date}_${name}.zip",
"objectSchemaId":"${i}",
"includeObjects":"true",
"password":"${archpwd}",
"objectSchemaName":"${name}",
"totalObjectsInExport":"${countobj}"
}
EOF
}

status_code=$(
curl -s -u ${username}:${password} \
        -H "Content-Type: application/json" \
        --write-out %{http_code} \
        --silent \
        --connect-timeout 5 \
        -X POST \
        --output "/dev/null" \
        --data "$(param)" \
        "${url}${exportreq}"
)

if [ $status_code -ne 200 ] ; then
    echo "Site bad status (${date}_${name}.zip): $status_code"
else
    echo "Site good status (${date}_${name}.zip): $status_code"
fi

done
exit

 

 

Like # people like this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events