Import-export REST API option settings

Junya Fujiyoshi shared this question 11 months ago
Answered

May I ask one question regarding the option settings when importing Yellowfin contents via import-export REST API.

I am writing the code to import Yellowfin contents via REST API.
When importing contents via REST API without setting options, this programing code works fine and contents are successfully imported.

Meanwhile when options are set, the code does not work.
For instance, attached "get-import-content.json" is the dependencies for the passed list of content. I want to skip importing the View and attach the Report to the existing View. For this purpose, when the below lines are added, the code noes not work.


--form "importOptions=[{itemIndex: 1, optionKey: 'SKIP', optionValue:\'TRUE\'},{itemIndex: 5, optionKey: 'VIEW', optionValue:105255}};type=application/json"
Could you kindly give me advices what is wrong in my option settings?

Replies (26)

photo
1

Hi Junya,

Thanks for reaching out to Yellowfin support.

Could you please share the info.jsp file to troubleshoot on this issue? To access this page, just append info.jsp to your YF URL.
E.g. http://localhost:8080/info.jsp

Regards,

Sri Vamsi

photo
1

Hi Vamsi,

Thank you very much for your quick response.

Please see the attached, information obtained with info.jsp.

Regards,

Junya

photo
1

Hi Junya,

Greetings of the Day!

I would like to have a remote session with you regarding this issue. I'll be available in between 9 PM IST to 6 AM IST. Could your please let me know your available time to schedule a meeting?

Regards,

Sri Vamsi

photo
1

Hi Vamsi,

National holiday starts from tomorrow May 3 till May 7 in Japan. Hence I will be available 9:30 am - 14:30 pm IST on May 8 at earliest.

By the way, is it possible sharing the sample code of option settings?

Though syntax is shown in Response Sample on ReDoc site below, I simply cannot understand how to set options to skip importing the View and attach the Report to the existing View.

https://developers.yellowfinbi.com/dev/api-docs/current/#operation/importContent

photo
1

Hi Junya,

Please let me know once you are available. We will have a remote session and we can work on this issue.

Regards,

Sri Vamsi

photo
1

Hi,

I will be available today 9:30 am - 14:30 pm IST.

Junya

photo
1

Hi Junya,

Thanks for your reply.

I'll be available in between 9 PM IST to 6 AM IST but if it doesn't work for you let me know. I'll try to connect in your available time zone (9:30 am - 14:30 pm IST).

Regards,

Sri Vamsi

photo
1

Hi Junya,

I just want to touch base to see if you had chance to read through my response. If you can let me know your availability that would be great.

Regards,

Sri Vamsi

photo
1

Hi Vamsi,

I think it is not easy to adjust to the different time zone each other.

Then, as described in my previous post, is it possible sharing the sample code of option settings?

If there is a sample code of option settings, it will be very helpful.

Regards,

Junya

photo
1

Hi Junya,

Can you please try the below code and do let me know if it is working for you. I can see that the code you have mentioned is opened with square bracket and closed with curl bracket, I have modified that code as below.

--form "importOptions=[{itemIndex: 1, optionKey: 'SKIP', optionValue:'TRUE'}, {itemIndex: 5, optionKey: 'VIEW', optionValue: 105255}];type=application/json"

Please let me know how it goes.

Regards,

Sri Vamsi

photo
1

Hi Vamsi,

Though I tried the modified code, it did not work.

I feel this problem will not be resolved.

I will consider the workaround.

Regards,

Junya

photo
1

Hi Junya,

You're saying that importing content via REST calls is working fine for you without including any import options.

Would you mind sharing your code for this process, I'm trying to import using java but failing to do so getting only 500 without no server logs to debug.

Thanks and best regards!

Elvis

photo
1

Hi Junya,

Could you please share the logs and error message with time stamp. And it would be great if you can provide the work around steps here.

Regards,

Sri Vamsi

photo
1

Hi Vamsi and Elvis,


Please see the attached "yellowfin.log" in which error log is found.

In addition, in the console, below message is shown.

{"code":500,"reason":"INTERNAL_SERVER_ERROR","description":"Error importing via REST API"}
Meanwhile I did not find any workaround so far.


I have created this program with php.

Please see below.

If you create the same logic with java/jsp, could you kindly share it here?



<?php
//Variables
$adminId = 'admin@yellowfin.com.au';
$adminPassword = 'test';
$time = ceil(microtime(true)*1000);
$url = 'http://localhost:9820/api/refresh-tokens';
$url2 = 'http://localhost:9820/api/access-tokens';
$refreshToken = "";
$accessToken = "";

//Refresh-token
$header = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123',
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json;charset=UTF-8'
);

$body = array(
'userName'=>$adminId,
'password'=>$adminPassword
);
$body_json = json_encode($body, JSON_PRETTY_PRINT);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$json_result = json_decode($result);
$refreshToken = $json_result->securityToken;
curl_close($ch);

//Access-tonek
$header2 = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123, token='.$refreshToken,
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json'
);

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_HTTPHEADER, $header2);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch2, CURLOPT_POSTFIELDS, '');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_URL, $url2);
curl_close($ch);
$result2 = curl_exec($ch2);
$json_result2 = json_decode($result2);
$accessToken=$json_result2->securityToken;

//Import contents
$text ='curl -X "POST" "http://localhost:9820/api/rpc/import-export/import-content" ';
$text = $text.'-H "Accept: application/vnd.yellowfin.api-v2+json" ';
$text = $text.'-H "Authorization: YELLOWFIN ts='.$time.', nonce=123, token='.$accessToken.'" ';
$text = $text.'-H "Content-Type: multipart/form-data" -H "cache-control: no-cache" ';
$text = $text.'--form "contentToProcess=@export.yfx;type=application/octet-stream" ';
echo exec($text);
?>


Regards,

Junya

photo
1

Hi Junya,

Could you please allow me some time to review the attached logs and I'll get back to you with an update.

Regards,

Sri Vamsi

photo
1

Hi Junya,

Could you please let me know which API and Version you are having this issue?

And also could you please let me know when did you start to see this error. Are you encountering this issue for the first time?


Regards,

Sri Vamsi

photo
1

Hi Vamsi,


I am having this issue with 9.7.x and 9.8.x, and started encountering this issue with version 9.7.


Regards,

Junya

photo
1

Hi Junya,

Could you please let me know the API and its version as well?

Regards,
Sri Vamsi

photo
1

Hi,

REST API version is 2.0.

Regards,
Junya

photo
1

Hi Junya,

Greetings of the Day!

I would like to clarify few things here:

1. As you mentioned earlier, the query below, does the itemindex:1 and itemindex 5 have any dependency?

--form "importOptions={{itemIndex: 1, optionKey: 'SKIP', optionValue:\'TRUE\'},{itemIndex: 5, optionKey: 'VIEW', optionValue:skip}};type=application/json"

2. Could you please check the option value 105255 exist in DB by running the below query because when we tried with the code we have seen different value for itemindex:5.

select * from ReportView -- From this table you can find the option Value

3. Can you please try skipping the itemindex value 5 as below

--form "importOptions={{itemIndex: 1, optionKey: 'SKIP', optionValue:\'TRUE\'},{itemIndex: 5, optionKey: 'VIEW', optionValue:'SKIP'}};type=application/json"

Could you please try this and let me know how it goes

5b00a95bc8848fc2ef7093c450bc9c85

Regards,

Sri Vamsi

photo
1

Hi Vamsi,

I have repeated the same steps by exporting new contents.
I answer to your three questions within the following steps.

1) Export the report named "Export Report" into export.yfx.

2) Get contents included in export.yfx via /import-export/get-import-content api.

The response is:

{
	"items": [
		{
			"resourceName": "demo",
			"resourceDescription": "",
			"resourceId": 108094,
			"resourceUUID": "905cfe26-8ed3-4e4b-a143-71ef826bec51",
			"resourceType": "DATASOURCE"
		},
		{
			"resourceName": "Export View",
			"resourceDescription": "",
			"resourceId": 188992,
			"resourceUUID": "2682d6aa-432a-4ca5-90a4-ba112dc7bbc6",
			"resourceType": "VIEW"
		},
		{
			"resourceName": "export",
			"resourceId": 188990,
			"resourceUUID": "49a2aea0-8cb8-47d9-bf4b-0043986b2ed3",
			"resourceType": "RPTCATEGORY",
			"resourceCode": "EXPORT"
		},
		{
			"resourceName": "content",
			"resourceId": 188991,
			"resourceUUID": "07cc0610-3926-40bc-b61c-b4c9c88c1994",
			"resourceType": "RPTSUBCATEGORY",
			"resourceCode": "CONTENT"
		},
		{
			"resourceName": "Export Report",
			"resourceDescription": "",
			"resourceId": 188999,
			"resourceUUID": "6de32683-4750-4afe-97ee-476a5113eb3d",
			"resourceType": "REPORT"
		}
	],
	"_links": {
		"menu": {
			"href": "/api/menus/mobile-menu",
			"options": [
				"GET"
			]
		},
		"api": {
			"href": "/api",
			"options": [
				"GET"
			]
		},
		"self": {
			"href": "/api/rpc/import-export/get-import-content",
			"options": [
				"POST"
			]
		}
	}
}

3) I would like to skip importing DATASOURCE and VIEW from export.yfx, and attach report to existing View.

4) Confirm that the View exist running the following query, and its response is as attached "Query Result.png".

select viewid, viewname, viewdescription, viewstatuscode, creationdate from reportview where viewid = 188992;
5) If option is not set when importing export.yfx by running the following PHP code, the import process success and all contents are imported.

<?php
//Variables
$adminId = 'admin@yellowfin.com.au';
$adminPassword = 'test';
$time = ceil(microtime(true)*1000);
$url = 'http://localhost:9820/api/refresh-tokens';
$url2 = 'http://localhost:9820/api/access-tokens';
$refreshToken = "";
$accessToken = "";

//Refresh-token
$header = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123',
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json;charset=UTF-8'
);

$body = array(
'userName'=>$adminId,
'password'=>$adminPassword
);
$body_json = json_encode($body, JSON_PRETTY_PRINT);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$json_result = json_decode($result);
$refreshToken = $json_result->securityToken;
curl_close($ch);

//Access-tonek
$header2 = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123, token='.$refreshToken,
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json'
);

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_HTTPHEADER, $header2);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch2, CURLOPT_POSTFIELDS, '');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_URL, $url2);
curl_close($ch);
$result2 = curl_exec($ch2);
$json_result2 = json_decode($result2);
$accessToken=$json_result2->securityToken;

//Import contents
$text ='curl -X "POST" "http://localhost:9820/api/rpc/import-export/import-content" ';
$text = $text.'-H "Accept: application/vnd.yellowfin.api-v2+json" ';
$text = $text.'-H "Authorization: YELLOWFIN ts='.$time.', nonce=123, token='.$accessToken.'" ';
$text = $text.'-H "Content-Type: multipart/form-data" -H "cache-control: no-cache" ';
$text = $text.'--form "contentToProcess=@export.yfx;type=application/octet-stream" ';
echo exec($text);
?>

6) If options are set when importing export.yfx running the following PHP code, the import process does not success.

<?php
//Variables
$adminId = 'admin@yellowfin.com.au';
$adminPassword = 'test';
$time = ceil(microtime(true)*1000);
$url = 'http://localhost:9820/api/refresh-tokens';
$url2 = 'http://localhost:9820/api/access-tokens';
$refreshToken = "";
$accessToken = "";

//Refresh-token
$header = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123',
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json;charset=UTF-8'
);

$body = array(
'userName'=>$adminId,
'password'=>$adminPassword
);
$body_json = json_encode($body, JSON_PRETTY_PRINT);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$json_result = json_decode($result);
$refreshToken = $json_result->securityToken;
curl_close($ch);

//Access-tonek
$header2 = array(
'Authorization:YELLOWFIN ts='.$time.', nonce=123, token='.$refreshToken,
'Accept:application/vnd.yellowfin.api-v2+json',
'Content-Type:application/json'
);

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_HTTPHEADER, $header2);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch2, CURLOPT_POSTFIELDS, '');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_URL, $url2);
curl_close($ch);
$result2 = curl_exec($ch2);
$json_result2 = json_decode($result2);
$accessToken=$json_result2->securityToken;

//Import contents
$text ='curl -X "POST" "http://localhost:9820/api/rpc/import-export/import-content" ';
$text = $text.'-H "Accept: application/vnd.yellowfin.api-v2+json" ';
$text = $text.'-H "Authorization: YELLOWFIN ts='.$time.', nonce=123, token='.$accessToken.'" ';
$text = $text.'-H "Content-Type: multipart/form-data" -H "cache-control: no-cache" ';
$text = $text.'--form "contentToProcess=@export.yfx;type=application/octet-stream" ';
$text = $text.'--form "importOptions=[{itemIndex: 0, optionKey: \'SKIP\', optionValue:\'TRUE\'},{itemIndex: 1, optionKey: \'SKIP\', optionValue:\'TRUE\'},{itemIndex:4, optionKey: \'VIEW\', optionValue:\'188992\'}];type=application/json"';
echo exec($text);
?>
7) itemIndex 4 is the report in this case, not the one to skip importing.

photo
1

Hi Junya,

Thanks for your response.

Please allow us sometime. I'll check with our wider team and get back to you with an update.

Regards,

Sri Vamsi

photo
1

Hi Junya,

Greetings of the day!

I have raised a Jira task to our product team. I'll keep you posted once we receive an update from our product team.

Regards,

Sri Vamsi

photo
1

Hello Junya,

Greetings of the Day!

I trust this email finds you well. I wanted to follow up on your recent query and ensure that our product team was able to provide the clarity you were looking. Could you please let us know If you have any additional questions.

Regards,

Sri Vamsi

photo
1

Hi,

I have confirmed the following option works with CI Build.

{itemIndex:4, optionKey: \'VIEW\', optionValue:\'VIEW100848\'}

Thank you very much!!

Regards,

Junya

photo
1

Hi Junya,

Thanks for your response.

That's great to hear! If that's all good, I'll go ahead and mark this as complete. Feel welcome to reach out in the future.

Regards,

Sri Vamsi

Leave a Comment
 
Attach a file