API key to publish to JMP Live/PublicI remember in a recent JMP Live call there was explanation that we needed to include an API key in our JSL to publish to JMP Live/Public. Does anyone have details of this? I've gone through 10 useful tips for automating the publishing of JMP Live reports but the API key is not included in these instructions yet.
Also, is there anyway to direct the publish to JMP Live or Public? Would seem that the destination is hardwired into the settings for JSL.
Re: API key to publish to JMP Live/PublicHelpful post! Two more questions:
1. How in general does the Credentials file you include look like?
2. When I just want to update the data table, it seems adding API Key does not work as argument. As well it does not like the package-id I get when searching for the post and use the returned ID. Any sample script for that?
Thanks a lot
Re: API key to publish to JMP Live/PublicThank you for these, they have both helped so have marked as co-solutions!
Now just dealing with an odd timeout situation posting to JMP Live and Public.
Re: API key to publish to JMP Live/PublicLikewise I do something like:
url = "";
user = "";
api_key = "";
title = "My Report";
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dis = dt << Run Script( "Distribution" );
biv = dt << Run Script( "Bivariate" );
webrpt = New Web Report();
webrpt << Add Reports( {dis, biv} );
url = webrpt << Publish(
URL( url ),
Username( user ),
Prompt( IfNeeded ),
Title( title ),
API Key(api_key)
);
If(url != "",
web(url);
)
Ryan has Prompt (Never) which is the default, however, I use Prompt (ifNeeded) since I cannot get my script right the first time. The ifNeeded will prompt you for your credential using the new authentication for 15.1 (and up) given that you are publishing to a JMP 15.1 (15.2) or 16 JMP Live. Keep in mind you cannot publish from JMP 15 (15.1, 15.2) to JMP 16 (or vice versa)
The first publish will securely save your tokens (user and url) which is not the same as user/password securely. Alternatively, you can use JMP Live Connect to store your tokens. additionally JMP Live Connect can save the api_key if you don't want to add it to the publish command.
API keys are obtained from your JMP Live server user profile. There's a "Generate API Key". If you generate one, it will generate a new one. This means that the old ones will not work anymore. You'll want to save the API key for future use with that server.
API Keys are unique to the user and publish url. That is, a key from jmplivesales will not work on devlive15 or a key that's valid for sasbeb will not work with Bryan.Boone@jmp.com
Re: API key to publish to JMP Live/PublicHere's the code that I use for publishing to JMP Live that includes the API key parameter. The value given to the URL parameter is used to direct the publish to the appropriate JMP Live instance.
Names Default To Here( 1 );
Include( "JMPLiveCredentials.jsl" );
JMPLive = New Namespace(
"JMPLive"
);
JMPLive:Initialize() = Function( {},
{},
JMPLive:key = Credentials:key;
JMPLive:server = Credentials:server;
);
JMPLive:Publish Report = Function( {web_report, package_id = Empty()},
publishExpr = Expr(
Publish(
Prompt( Never ),
URL( JMPLive:server ),
API key( JMPLive:key ),
Public( 0 ),
Publish Data( 1 )
)
);
If( !Is Empty( package_id ),
Insert Into( publishExpr, Expr( Replace( package_id, Prompt( Never ) ) ) )
);
Eval( Substitute( Expr( web_report << publishMessage ), Expr( publishMessage ), Name Expr( publishExpr ) ) );
);
JMPLive:Initialize();
then do something similar to the following:
report = New Web Report();
report << Add Report(
Community_Graphs:Create Graph of Actions(),
Title( "JMP Community - Actions" ),
Description( "Displays the actions taken by users" )
);
// To replace a report
JMPLive:Publish Report( report, "zsa8Hypq021n" );
// To create a new report
JMPLive:Publish Report( report );
Hope that helps.