Use REST API from javascript client in custom page

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
Posts: 106

Use REST API from javascript client in custom page

Post by Andros »

Hi, I have a "photos" table, and a custom page which shows some photos. With every photo there is an icon to delete it.
I want to let the user to click the icon, request a confirmation, and if yes deletes the image and refreshes the page.
The click generates a 401 Unauthorized error. Do I have to create the JWT? Is there any way to reuse the current sessione JWT?

var photos=ExecuteRows("SELECT * FROM photos;");
foreach (Dictionary<string, object> img in photos) {
<a href="#" class="deleteimg" data-id="@img["PhotoID"]"><i class="fa fa-trash"></i></a>

			$.get("api/delete/photos/" + $(this).data('id'), function(res) {
				if (res && res.success) {
					var row = res[object];
					alert(JSON.stringify(row)); // Show output JSON
				} else {

Posts: 1017

Post by MichaelG »

For API request, you should always use the JWT Token. Please read: ... -web-token

If you have enabled Include common files for your custom file, you should be able to retrieve the JWT token from: ew.API_JWT_TOKEN

Post Reply