External API

Hi,

In the API tester why the data shows like this, with lots of backslashes?


When setting the API endpoint in the global then the data that it fetches is stored in data? Like I could access the keys, data.status or how? I tried but nothing, see the fields from the screenshot referenced above.

Thanks

Hey Abd,

The backslashes are used to escape special characters within the JSON string. In JSON, characters like double quotes (") have special meaning (they delimit strings). To include a literal double quote within a string, it must be escaped with a backslash (").

How do I do that? Could you explain? Also about the data, what should I target to access the keys?

I’m sending you credentials to have a look at the issue what I’m having with it.

Hello @abdurrehman,

We cannot access the given site. Please check the screenshot below.

Thanks.

I know why is that because you’d access to other site and currently logged in with that user that’s why not able to login, please log out from the user you’re logged in with another site and these credentials should work fine as when I shared then checked them as well.

Hey @abdurrehman,

You should have this Looper Provider API settings:

With the help of the {{dc:looper:debug_consumer}}, you can get this:

You can use it to access the data:

<p>Status: {{dc:looper:field key="status"}}</p>
<p>Username: {{dc:looper:field key="data.username"}}</p>

Hope this helps.

I don’t see anything from the debug on my end and if this is the loop consumer then where does it getting the looper provider data though?

Hi @abdurrehman,

I have checked and found that the Column already has the External API looper provider and the looper consumer enabled. So in that case, the data is available in any elements which use the Dynamic Content with the proper field name as explained by my colleague. You can check the API response in a proper format, which shows the fields and the values.

image

Hope it helps.
Thanks

When the data is collected from the API, what is that called? I mean how to target a specific item? Is that data always or what? For example, targeting the isVerified

Hi @abdurrehman,

The Data Key changes based on the API responses. For the API you are using it is data, whereas in the sample API it is results. So you need to target based on that.
Here, you need to use data.isVerified as my colleague explained in his reply to get the username.

{{dc:looper:field key="data.isVerified"}}

Hope it helps.
Thanks

Can you take a look at the page in notes and see why that’s not pulling that through?

Also, why it has added the \n in the data from the endpoint? How to remove that?

Hi @abdurrehman,

I checked the response coming from the API, and it is not in the JSON format. So you need to convert the response into the JSON or any other format that Looper Provider can understand. You can check with the API provider on that to get the JSON response.
As this response is not properly formatted, it does not show the rest of the output expected.

Thanks

So will it only fetch that when it’s a JSON output? and doesn’t render the .txt file?

Hi @abdurrehman,

The Looper always expects properly formatted values like JSON or Array, which can be traversed in the loop.

Thanks

Since the data is not an object like your JSON requests. In this case for your TXT file you can just use {{dc:looper:item}} to output the data. As for the \n issue, you can add this into a <pre> tag to have the new lines properly outputted. I added this to the test page you sent use. Have a great day.

<pre>{{dc:looper:item}}</pre>

Thank you, this was what wanted to know. How could I figure it out which one to use? I mean this item I didn’t find it anywhere, in docs or knew it before. So how to know when it’s data or item or something else?

I added some docs to the “Raw” return type. Thanks for the suggestion. Have a great weekend.

Thanks, chaning the font family doens’t seem to work.


Do I have to add more weight to it to force the styles with Custom CSS?

Hey @abdurrehman,

You are trying to return the changelog from the API and the API returns the changelog status wrapped with the <pre> HTML tag.

You will need to add custom CSS to change the font or modify the attribute of the changelog status. For example;

.x-text.x-content pre {
   /* your styling here */
}

Hope this makes sense.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.