Utilizing Liferay 6.0.6's JSON API to Enhance JavaScript Functionality

I am seeking a way to access data from the Liferay portal using its JSON API through JavaScript client by making AJAX calls.

After some research, I was able to find the address for the API :

http://127.0.0.1:8080/tunnel-web/secure/json

There is also a SOAP web service available at this address:

http://127.0.0.1/:8080/tunnel-web/secure/axis

Upon authentication, the SOAP version returns a list of services with WSDL descriptors, but the JSON version does not display anything (with an HTTP status of 200).

I attempted a request like this one:

http://127.0.0.1:8080/tunnel-web/secure/json?serviceClassName=com.liferay%C2%AD.portal.service.CountryServiceUtil&serviceMethodName=getCountries

This resulted in a 404 error: HTTP Status 404 - /tunnel-web/c/portal/status "Resource is not available"

What could be causing this issue? How can I retrieve the data in JSON format?

Running on Liferay 6.06

Thank you for any assistance :)

EDIT :

Please note that I have successfully passed the authentication process, either by providing login credentials when prompted by the browser or by including them in the URL:

http://login:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5d5c4d6d6d2cad7c1e59497928b958b94">[email protected]</a>:8080/...

Therefore, authentication is not the cause of the issue here :/

Answer №1

I have not personally attempted this yet, but I believe that liferay's secure webservices require credentials for access.

Before proceeding, make sure to verify your authentication type in the portal-ext.properties file:

company.security.auth.type=screenName

Then you can try accessing using the following URL format:

http://" + [userId / sreenName] + ":" + password + "@<server.com>:<port>/api/secure/axis/" + serviceName

REFERENCE

Answer №2

Sorry for the mistake on my part.

It seems that the ServiceClassName in my request has been corrupted by some "%C2%AD" characters:

http://login:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5222332121253d2036126360657c627c627c63">[email protected]</a>:8080/tunnel-web/secure/json?serviceClassName=com.liferay%C2%AD.portal.service.CountryServiceUtil&serviceMethodName=getCountries

That's where the issue lies.

I have fixed it by removing them:

http://login:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9a9b8aaaaaeb6abbd99e8ebeef7e9f7e9f7e8">[email protected]</a>:8080/tunnel-web/secure/json?serviceClassName=com.liferay.portal.service.CountryServiceUtil&serviceMethodName=getCountries

A helpful clue was found here: a discussion thread regarding JSON web service requests with formatting.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Strange image resizing issues observed during refresh

Every time I refresh the page, I am faced with this strange resizing issue showcased in the GIF below: https://i.sstatic.net/tzlYTUyf.gif The image appears to be resized in an odd manner. <WifiWidgetContainer> <Image ...

The element within the array object is not properly defined and is causing error messages to be displayed

Whenever I try to use Icons[link.label] in my const, I receive the following error message: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'iconsProps'. No index sig ...

Prevent clicking on the <div> element for a duration of 200 milliseconds

I need to make this box move up and down, but prevent users from clicking it rapidly multiple times to watch it go up and down too quickly. How can I add a 200 millisecond delay on the click or disable clicking for that duration? View the jsfiddle example ...

Dividing an array of characters within an ng-repeat and assigning each character to its individual input tag

Hello, I'm currently learning Angular and I have a unique challenge. I want to take the names in a table and break each name into individual <input> tags, so that when a user clicks on a letter, only that letter is selected in the input tag. For ...

Value binding in Angular being passed to ng-click function rather than the actual value

An HTML link is causing me some trouble: <div class="menu-item" ng-repeat="pageName in pages"> <a ng-click="routing.open('{{pageName}}')">{{pageName}}</a> </div> When clicked, this link triggers the 'open' ...

Is there a way to arrange an array based on the product or quotient of two values?

I'm working with an array of posts, each containing data on 'views' and 'likes', along with the user IDs associated with those likes. My goal is to sort this array based on the like rate. However, my current approach seems to be i ...

Discovering numbers within a JSON object and extracting them - a step-by-step guide

If I have a JSON object coming from a random dataset and want to search through it to manipulate the number values, how can I achieve this? Looping through the object using for...of allows me to get the keys, but I'm unsure how to access every key-val ...

Tips on conducting a statistical analysis without having to wait for the completion of an AJAX response

I am looking to track the number of clicks on a specific div with the id #counter and then redirect the user to a different website. To achieve this, I have implemented an ajax call on the click event of the #counter div. Upon successful completion of the ...

Using jQuery to iterate through table rows generated by PHP and targeting a particular row based on a specific condition

I'm working on a project where I have a dynamically created table populated from a MySQL database. The task at hand is to create a modal dialog that displays the values of a specific row when a user clicks the view button. I am using jQuery along with ...

Increase the size of images on the same screen with a click using WP Metas

Currently, I am utilizing WP Metaslider for a slideshow/gallery presentation. While it is functioning well, I would like to enhance the user experience by allowing the images in the slider to enlarge within the slide when clicked on, rather than opening in ...

I encountered an error while trying to launch my server using Docker

https://i.sstatic.net/k7Otf.png My node JS server running in docker is throwing an error after a successful build. I have tried deleting the docker image, but it did not resolve the issue. ...

An error occurred while trying to load the resource in the Redux-Saga: connection refused

Utilizing axios allows me to make calls to the backend server, while redux-saga helps in managing side effects from the server seamlessly. import {call, put, takeEvery} from "redux-saga/effects"; import {REQUEST_FAILED, REQUEST_SUCCESS, ROOT_URL, SUBMIT_U ...

Caution: React alert for utilizing the UNSAFE_componentWillReceiveProps in strict mode

As a newcomer to React, I encountered a warning that has me stuck. Despite researching extensively online, I still can't resolve it. The warning message is: https://i.stack.imgur.com/4yNsc.png Here are the relevant portions of the code in App.tsx: ...

Getting Started with NodeJS Child Process for Electrons

My current challenge involves integrating a Gulp setup with debugging electron-quick-start. I am attempting to close and reopen Electron when changes are made to my source files using child_process.spawn. Launching the application seems to work fine, but w ...

What is the best way to retrieve JSON data using JavaScript within a loop?

I'm struggling to retrieve data from a JSON object. Here's the JSON structure I'm working with: var data = [ {"mes":{ "January":{ "Inversion":"1000","Fans":"1020"} ...

Creating a many-to-many relationship in Loopback4 with NodeJS

As I work on constructing a blog API with Loopback 4 framework, I've hit a snag in finding information on how to establish many-to-many relationships between Posts and Categories. Despite searching through the documentation and various online articles ...

Ways to troubleshoot opencv.js generating random values when applying cv.threshold

Whenever I choose an image and use cv.threshold, it outputs a strange number 6620912 The number seems to change at times https://i.sstatic.net/Tp9LP.png 6620912 Promise.catch (async) (anonymous) @ App.tsx:49 commitHookEffectListMount @ react-dom_client ...

What could be the reason for the Puppeteer script returning 'undefined' when using ExecutionContext.evaluateHandle()?

Currently, I am in the process of learning the Puppeteer API with version 1.9.0. Below is the code I am using to click a button within an iframe: const changePrefsFromAllToNone = async () => { try { const browser = await puppeteer.launch ...

Guide on invoking the server-side method in Office 365 using JavaScript files

Exploring the capabilities of office 365 API apps and looking for documentation on how to access specific row(s) and cell(s) values / select a particular sheet programmatically in a .js file. Currently, I am utilizing the following code within a function: ...

Tips on using an array filter in AngularJS ng-repeat

I have successfully used ng-repeat to display my data. Within the ng-repeat result set, one of the data fields is an array of items. Example: {x:1, y:[2,3,4]} I want to filter the data based on the values inside the array. Filtering by non-array data is ...