Forum Discussion

abhinavjha's avatar
abhinavjha
New Contributor II
4 years ago

Wrong output of Script

I tried running a script but after few rows, the data from different column started to show.
For example, I tried loading data in column index 114. It is showing correct data till almost half number of rows but after that it is showing data of column 112.
I am attaching snippet of my code.

Column R took value of Column P. Also column P shifted.

  • @vincenr : Based on your question, I’m assuming that you are looking at this documentation page. That page will be deprecated soon and a note at the top of the page includes links to the new topics that replace it.

    The newer topic that seems most applicable to the API you want is this page, which shows that the API no longer requires the org_wide parameter. If you don’t specify a project filter, you’ll get results for all projects in the Org.

    I hope that helps.

    • vincenr's avatar
      vincenr
      New Contributor III

      When I remove everything but the ‘last_hours’ parameter, I do not get everything in our org… all I get is whatever has run at the root of our org directory, not all of the projects subsumed under the org directory. So, please help me out here.

      • Eleanor's avatar
        Eleanor
        Employee

        @vincenr: Are you an Org admin for the Org? If not, you’ll only see what you have permissions to see.

        If you are an Org admin, yes, please file a ticket.

    • vincenr's avatar
      vincenr
      New Contributor III

      Do I need to open a ticket or will someone clarify (see my latest question on community)…?

  • vincenr's avatar
    vincenr
    New Contributor III

    Ok, so I downloaded a pipeline I found on your site and it works, but I’m confused as to why mine won’t work using the following:

    https://elastic.snaplogic.com/api/1/rest/public/runtime/” + _org + “?last_hours=” + _last_hours + “?state=” + _state

    The one I found (below) is much more complicated and I don’t want to just use it without understanding why mine doesn’t work. So obviously, I have rights to see “everything”.

    https://elastic.snaplogic.com/api/1/rest/public/runtime/’ + pipe.plexPath.split(‘/’)[1] + ‘?level=summary’ + (_state == null || _state ==“” ? ‘’ : ‘&state=’+ _state) + (_hours == null || _hours ==“” ? ‘’ : ‘&last_hours=’+ _hours) + (_batchsize == null || _batchsize ==“” ? ‘’ : ‘&limit=’+ _batchsize)

    My ‘_org’ is preset to our org, but I’ll probably change it to the more generic one.
    I do realize a lot of that has nothing to do with the data I want to see, but load balancing for paging.

    There was a high level explanation of the api call directly above on the article I found, but not why all the gymnastics with the state parameter and the hours parameter. Also, the ‘level’ parm is not listed on the page you referred me to.

    • koryknick's avatar
      koryknick
      Employee

      Breaking this command down into the individual elements for explanation:

      First is just the path of the API call:
      ‘https://elastic.snaplogic.com/api/1/rest/public/runtime/’

      Next is a dynamic way of specifying the org that the pipeline executing the REST GET - pipe.plexPath is a built-in property that gives the full path of the pipeline being executed, then we break that string down into an array of strings using the String.split() method, and finally grab only the array element at index 1.

      + pipe.plexPath.split(‘/’)[1]
      

      Finally, we are using some pipeline parameters to build out the remaining query elements in the URL. If you are not familiar with ternary operators, please take a look at the “Special Operators” section of the Expression Operators documentation.

      + ‘?level=summary’ + (_state == null || _state ==“” ? ‘’ : ‘&state=’+ _state) 
      + (_hours == null || _hours ==“” ? ‘’ : ‘&last_hours=’+ _hours) 
      + (_batchsize == null || _batchsize ==“” ? ‘’ : ‘&limit=’+ _batchsize)`
      

      I hope this helps!