Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

String index out of range

I'm creating an API Profile to Harvest. I can connect with curl like this:

curl "https://humanity34.humanity.com/app/" -H "origin: https://humanity34.humanity.com" -H "x-requested-with: XMLHttpRequest" --data "key=<mykey>=staff.login&method=GET&username=<myusername>&password=<mypassword>"

If use the JSON file curl generates as my URI then all is well. Now I'm trying to generate what the curl example does myself.

My API profile looks like this:

<rsb:set attr="Header:Name#" value="Origin" />
<rsb:set attr="Header:Value#" value="https://humanity34.humanity.com" />
<rsb:set attr="Header:Name#" value="x-requested-with" />
<rsb:set attr="Header:Value#" value="XMLHttpRequest" />
<rsb:script method="POST" >

<rsb:set attr="method" value="POST"/>

<rsb:set attr="data" value="key=<mykey>&amp;module=staff.login&amp;method=GET&amp;username=<my user name>&amp;password=<mypassword>" />
</rsb:script>

<rsb:set attr="uri" value="https://humanity34.humanity.com/app/" />

I've a few variants of this, but whenever I try to fetch data I always get the error "String index out of range: -1". Any clues as to what is wrong here?

5 Community Answers

Matillion Agent  

Laura Malins —

Hi Quinn

It’s very hard to test without working credentials, however I think the issue here is that you’re trying to connect to a webpage not the api. Looking at the response for the above it shows HTML. You should be able to use this endpoint to get the data you want:

https://platform.humanity.com/

Thanks
Laura


Quinn Wildman —

We contacted Humanity support and they told us https://humanity34.humanity.com/app/ is the correct endpoint. It makes sense as it works with Curl. At this point, I've connected to quite a different API examples. The thing that's different with Humanity than any other example I've done is i have to send my credentials in a JSON string - as shown on my example. I converted that to a POST with my API example. My theory is that is where the problem lies. Any thoughts on this?

Is there any way to debug this error? To know what part of what line is the culprit?


Quinn Wildman —

I experimented some more and made a little simpler curl example and tried the API in a new way, but the same result. Here is the new curl example that works:

curl "https://www.humanity.com/app/" -H "origin: https://www.humanity.com" --data
"key=<your key>&module=staff.login&method=GET&username=<your username>&password=<your password>"

Here is my new API attempt:

<rsb:set attr="Header:Name#" value="Origin" />
<rsb:set attr="Header:Value#" value="https://www.humanity.com" />
<rsb:set attr="data"> {"key":"<my key>","module":"staff.login", "method":"GET","username":"<my user name>","password":"<My password>"}</rsb:set>
<rsb:set attr="uri" value="https://www..humanity.com/app/" />


Matillion Agent  

Laura Malins —

Hi Quinn

This is what the nested post will look like inside the API profile in Matillion:

<rsb:script xmlns:rsb="http://www.rssbus.com/ns/rsbscript/2/"> <rsb:info title="JSON POST" desc="Harvest" > <!-- Output column definitions --> <attr name="id" xs:type="string" other:xPath="id" /> <!--dummy columns for parameters --> <attr name="startdate" xs:type="string"/> <attr name="enddate" xs:type="string"/> </rsb:info> <rsb:set attr="uri" value="https://humanity34.humanity.com/app/" /> <rsb:set attr="RepeatElement" value="/" /> <rsb:set attr="Header:Name#" value="Origin" /> <rsb:set attr="Header:Value#" value="https://humanity34.humanity.com" /> <rsb:set attr="Header:Name#" value="x-requested-with" /> <rsb:set attr="Header:Value#" value="XMLHttpRequest" /> <rsb:set attr="ContentType" value="text/json;charset=UTF-8" /> <rsb:script method="GET" > <!-- Request an HTTP POST --> <rsb:set attr="method" value="POST"/> <rsb:set attr="data"> {"key":“<my key>”,“module”:“staff.login”, “method”:“GET”,“username”:“<my user name>”,“password”:“<My password>”} </rsb:set> <rsb:call op="jsonproviderGet"> <rsb:push/> </rsb:call> </rsb:script> </rsb:script>

However when I run this I still get your string out of index error. If you’re able to share some credentials with us I’m happy to test this to get you a working example?

Thanks
Laura


Matillion Agent  

Kalyan Arangam —

Hi Quinn,
Lets use the new ticket I’ve created. You may have already received a separate email on that.
I will close this ticket.

Best
Kalyan

Post Your Community Answer

To add an answer please login