ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
The Alteryx Community will be temporarily unavailable for a time due to scheduled maintenance on Thursday, April 22nd. Please plan accordingly.

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Java client for Alteryx Server API

DeepakTyagi
7 - Meteor

I need to connect to Alteryx Server API using a java client, does anyone have any pointers to use any existing one ?

DavidP
16 - Nebula
16 - Nebula

Have you seen this blog post from Andre de Vries? https://www.theinformationlab.co.uk/2017/12/21/use-alteryx-gallery-api-embed-apps-workflows/

 

He uses a javascript module and html test page to show how to interact with the Alteryx Gallery API.

mohankumarg
6 - Meteoroid

post the solution to the Community if you have solved it already.

ArtApa
Alteryx
Alteryx

Hi @DeepakTyagi - You can download a fully functional sample Alteryx client in C# or JavaScript from API documentation on our Gallery: https://gallery.alteryx.com/api-docs/ 

 

This is under Creating your own API client:

ArtApa_1-1610423834102.png

 

mohankumarg
6 - Meteoroid

We are actually looking for Java solution. Not Java Script. 

DeepakTyagi
7 - Meteor

We ended up using Spring boot template for this

mohankumarg
6 - Meteoroid

Please help share if any one has spring boot code. 

 

I was able to write some basic working code with scribe.  The details below.

 

 

Working Code Below:

import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.*;

import java.util.Map;

public class ScribeJavaMain {
    private static final String url ="https:// gallery.alteryx.com/gallery/api/v1/workflows/5ff71f96185f0201fc0437e5/jobs/";
    private static final String key ="YOUR_KEY_HERE";
    private static final String secret ="YOUR_SECRET_HERE";
    private static final String body="{\n" +
            "  \"questions\": [\n" +
            "    {\n" +
            "      \"name\": \"Cobdate\",\n" +
            "      \"value\": \"2020-01-01\"\n" +
            "    }\n" +
            "  ],\n" +
            "  \"priority\": \"0\"\n" +
            "}";
    public static void main(String[] args) {
        DefaultApi10a api = new DefaultApi10a() {
            @Override
            public String getRequestTokenEndpoint() {
                return null;
            }

            @Override
            public String getAccessTokenEndpoint() {
                return null;
            }

            @Override
            public String getAuthorizationUrl(Token requestToken) {
                return null;
            }
        };


        OAuthRequest request = new OAuthRequest(Verb.GET,url);
        request.addOAuthParameter(OAuthConstants.TIMESTAMP, api.getTimestampService().getTimestampInSeconds());
        request.addOAuthParameter(OAuthConstants.NONCE, api.getTimestampService().getNonce());
        request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, key);
        request.addOAuthParameter(OAuthConstants.SIGN_METHOD, api.getSignatureService().getSignatureMethod());
        request.addOAuthParameter(OAuthConstants.VERSION, "1.0");
        String baseString = api.getBaseStringExtractor().extract(request);
        System.out.println("baseString==>"+baseString);
        String signature = api.getSignatureService().getSignature(baseString, secret, "");
        System.out.println("signature==>"+signature);
        request.addOAuthParameter(OAuthConstants.SIGNATURE, signature);
        for (Map.Entry<String, String> entry : request.getOauthParameters().entrySet())
        {
            request.addQuerystringParameter(entry.getKey(), entry.getValue());
        }
        Response response2 = request.send();
        System.out.println(response2.getBody());
    }

}

 

Dependencies :

 

<dependency>
    <groupId>org.scribe</groupId>
    <artifactId>scribe</artifactId>
    <version>1.3.6</version>
</dependency>