Access OData services from two different system in SAP Web IDE - sapui5

I have two OData services on two different systems, for which I have added destinations in HCP and entries in neo-aap.json file.
{
"path": "/sap/opu/odata",
"target": {
"type": "destination",
"name": "ABC",
"entryPath": "/sap/opu/odata"
},
"description": "ABC"
}, {
"path": "/sap/opu/odata",
"target": {
"type": "destination",
"name": "XYZ",
"entryPath": "/sap/opu/odata"
},
"description": "XYZ"
}
With this, I'm able to access only one system's service i.e. OData service which is on ABC. When app loads app tries to load hit metadata for 2nd OData service as well in ABC which is obviously not there, hence fails.
How do I access the OData service on XYZ system?

If the 'path' is the same, only the first one will be matched. Set different paths for your destinations.
The 'path' property in the neo-app.json is just an alias for your destinations. With your config, this means, whenever in your app, you request something from '/sap/opu/odata/... ' the application will overwrite this part of the path with the URL you configured in the Destination.
Just make something like this:
{
"path": "/ABC/sap/opu/odata",
"target": {
"type": "destination",
"name": "ABC",
"entryPath": "/sap/opu/odata"
},
"description": "ABC"
}, {
"path": "/XYZ/sap/opu/odata",
"target": {
"type": "destination",
"name": "XYZ",
"entryPath": "/sap/opu/odata"
},
"description": "XYZ"
}
And then make sure you use "/ABC/sap/opu/odata" or "/XYZ/sap/opu/odata" whenever you set your model data sources.

This, from my perspective, is a bug.
The key used for locating the destination is the "path" value so you will always hit the first destination.
You can resolve this by changing the path from /sap/opu/odata to /sap/opu/odata1
You then edit your dataSources in your manifest.json: adjust the "uri" with the adjusted path on any models you are trying to point to the 2nd path.
I have written on this here and am busy trying to get SAP to change this behaviour.

Related

Add files to Salesforce CMS channel folder via Connect API?

I'm developing an integration that will programmatically create product entries in Salesforce, and part of that process needs to be the addition of product images. I'm using the Connect API and am able to make a GET call to the right folder like this (I've scrambled the IDs and what not for this example):
https://example.salesforce.com/services/data/v52.0/connect/cms/delivery/channels/0591G0000000006/contents/query?folderId=9Pu1M000000fxUMSYI
That returns a payload like this:
{
"currentPageUrl": "/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000006/contents/query?page=0&pageSize=250",
"items": [
{
"contentKey": "MCZ2YVCGLNSBETNIG5P5QMIS4KNA",
"contentNodes": {
"source": {
"fileName": "PET Round.jpg",
"isExternal": false,
"mediaType": "Image",
"mimeType": "image/jpeg",
"nodeType": "MediaSource",
"referenceId": "05T0R000005MthL",
"resourceUrl": "/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000007/media/MCY2YVCGLNSBETNIG5P4QMIS4KNA/content",
"unauthenticatedUrl": "/cms/delivery/media/MCZ2YVCGLNSBETNIG5P4QMIS4KNA",
"url": "/cms/delivery/media/MCY2YVCGLNSBETNIG5P4QMIS4KNA"
},
"title": {
"nodeType": "NameField",
"value": "844333"
}
},
"contentUrlName": "844333",
"language": "en_US",
"managedContentId": "20T0R0000008U9qUAE",
"publishedDate": "2021-08-18T16:20:57.000Z",
"title": "844333",
"type": "cms_image",
"typeLabel": "Image",
"unauthenticatedUrl": "/cms/delivery/v52.0/0DB1G0000008tfOWAU/contents/20Y0R0000008y9qUAE?oid=00D0R000000OI7GUAW"
}
]
}
I am also able to retrieve images by contentKey with a GET call like this:
https://example.salesforce.com/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000007/media/MCZ2ZVCGLNSBETMIG5P4QMIS4KNA/content
Anyone know what the endpoint should look like and what parameters etc it should have? I'm having trouble finding anything for this specific scenario in the docs but surely there's a way.
Thanks!

Arm template deployment fail with 409 error for one specific storage account

I use arm template to deploy a storage account. However, I got an error saying: StorageAccountAlreadyExists: The storage account named xxx already exists.
My release pipeline is set to incremental, so shouldn't really show this error.
I changed storage account name to a new one, not only it worked the first time, but I can keep on deploying the same pipeline and no error ever thrown out.
Looks like it is something specific to this account, however, I can't see anything special. The arm template we use is also quite normal (something we got from official examples before).
{
"$schema": "http://schema.management.azure.com/schemas/2019-06-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"StorageDescriptor": {
"type": "string",
"defaultValue": "StorageAccount",
"metadata": {}
},
"StorageAccountName": {
"type": "string",
"defaultValue": "[toLower(concat(parameters('StorageDescriptor'), resourceGroup().name))]",
"metadata": { "Description": "Override name for the storage account" }
},
"StorageType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS",
"Standard_RAGRS",
"Premium_LRS"
]
},
"Environment": {
"type": "string",
"defaultValue": "PreProd",
"metadata": { "description": "PreProd or Prod" }
}
},
"variables": {
},
"resources": [
{
"name": "[parameters('StorageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2019-06-01",
"dependsOn": [],
"tags": {
"displayName": "Web Job Storage Account"
},
"properties": {
"accountType": "[parameters('StorageType')]"
}
}
],
"outputs": {
}
}
Even though your release pipeline is set to incremental, the storage account name must be unique every time you deploy. Refer to: here.
Arm template deployment fail with 409 error for one specific storage account
You need to check if the storage account attributes have been changed through the Azure/PowerShell portal by somebody else, and are different than the ones specified on the ARM template.
To resolve this issue, please try to export the template and update it in the Azure devops repo:
Then, we could update this new exported template file as you want and deploy with it.
As test, I could keep on deploying the same pipeline and no error ever thrown out.

How to reuse a component from another application in UI5 1.38?

Environement
Framework : SAPUI5 V1.38.39
IDE : SAP WEB IDE
Problem
I want to use a SAPUI5 application in another one, in order to do so I found the following resource: https://blogs.sap.com/2017/04/05/sapui5-how-to-reuse-parts-of-a-sapui5-application-in-othermultiple-sapui5-applications/
Code from the app where I want to reuse another one
in component.js in init I used :
var sPath = sHostUrl.includes("webidetesting") ? "https://gtyext.net" : sHostUrl;
jQuery.sap.registerModulePath("ztntapp", `${sPath}/sap/bc/ui5_ui5/sap/ztntapp/`);
And in my view :
<core:ComponentContainer
name="ztntapp"
manifestFirst="true"
component="ztntapp">
</core:ComponentContainer>
and in neo-app.json
{
"path": "/sap/bc/ui5_ui5/sap/ztntapp/",
"target": {
"type": "destination",
"name": "gtyext_net",
"entryPath": "/sap/bc/ui5_ui5/sap/ztntapp/"
},
"description": "namespace.tntapp Resources"
}
Code from the reused app
in component.js
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"./model/models"
], function (UIComponent, Device, models) {
"use strict";
return UIComponent.extend("TrackAndTrace.ztntapp.Component", {
metadata: {
manifest: "json"
},
init: function () {
[...]
},
[...]
});
});
in neo-app.json (it is the default one created via SAP WebIDE):
{
"welcomeFile": "/webapp/index.html",
"routes": [
{
"path": "/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources",
"version": "1.38.45"
},
"description": "SAPUI5 Resources"
},
{
"path": "/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources",
"version": "1.38.45"
},
"description": "SAPUI5 Resources"
},
{
"path": "/webapp/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources",
"version": "1.38.45"
},
"description": "SAPUI5 Resources"
},
{
"path": "/webapp/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources",
"version": "1.38.45"
},
"description": "SAPUI5 Test Resources"
}
],
"sendWelcomeFileRedirect": true
}
Error message
Uncaught Error: failed to load 'ztntapp/Component.js' from
https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/Component.js:
Error: failed to load 'TrackAndTrace/ztntapp/model/models.js' from
resources/TrackAndTrace/ztntapp/model/models.js
Points with neo-app.json :
the application "ztntapp" itself works outside this application
the path for component.js is https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/Component.js however the path for model somehow become https://webidetesting278-a392f.dispatcher.hana.ondemand.com/webapp/resources/TrackAndTrace/ztntapp/model/models.js (I am not sure why "webapp/resources")
https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/model/models.js is found, resource should probably be loaded from here instead of /webapp/resources/TrackAndTrace/ but I don't know how to do so
Other research
With the neo-app.json file, the problem is to locate the resource
from the "ztntapp", I seen that there is also a
jQuery.sap.registerResourcePath but I am not sure how to use it for
this case
In your first application (main app) please use manifest.json to add the component usage instead of jQuery.sap.registerModulePath in Component.js:
"componentUsages": {
"ztntapp": {
"name": " TrackAndTrace.ztntapp",
"settings": {},
"componentData": {},
"lazy": true
}
}
Then you need to adjust your main app neo-app.json to enable Run configuration to reach your second app (reuse app)
"routes": [
{
"path": "/webapp/resources/TrackAndTrace/ztntapp",
"target": {
"type": "application",
"name": "ztntapp"
}
},
{
"path": "/resources/TrackAndTrace/ztntapp",
"target": {
"type": "application",
"name": "ztntapp"
}
},
Then for the resue app: Deploy your app, so it becomes registered within the SAP WebIDE Fullstack workspace.
Then for your main app in WebIDE, chose Run > Run Configurations > Add configuration > Run as Web Application > Advanced Settings mark Use my workspace first and then press Get Resource Versions. On the list below, you should see your reuse app listed under Resources Name:
Try with this :
jQuery.sap.registerModulePath("ztntapp", "/sap/bc/ui5_ui5/sap/ztntapp")
instead of
jQuery.sap.registerModulePath("ztntapp", ${sPath}/sap/bc/ui5_ui5/sap/ztntapp/)
Also check this link :
https://answers.sap.com/questions/668485/ui5-failed-to-load-componentjs-while-using-compone.html

Why Is "target" an Array?

I have the following route definition:
"routes": [{
"name": "overview",
"pattern": "",
"target": [
"overview"
]
}, {
"name": "customers",
"pattern": "/customers",
"target": [
"customers"
]
}, {
"name": "customer",
"pattern": "/customer/{id}",
"target": [
"customer"
]
}],
Why does the target property expect an array?
The value of the target property can be an array but it doesn't have to be, as stated in the API reference of sap.ui.core.Route:
The reason why it can await an array at all, is to support displaying multiple view (target) instances at once when navigating to a single route / navigating based on a certain hash value.
Source: Routing and Navigation
Example: The app is based on the Flexible Column Layout (formerly "Split-Screen" layout with sap.m.SplitApp) and the user visits it via a deep link having the hash value already e.g. #/Objects/ObjectID_14.
Source code
In this case, if only a single target name were assigned to the target property, only one of the views would have been able to be displayed. The target property can, however, contain multiple target names which will be then resolved and put based on the controlAggregation accordingly.
"routes": [
{
"name": "masterDetail",
"pattern": "Objects/{objectId}",
"target": [
"master",
"detail"
]
}
],
"targets": {
"master": {
"name": "Master",
"controlAggregation": "beginColumnPages"
},
"detail": {
"name": "Detail",
"controlAggregation": "midColumnPages"
}
}
To learn more about routing, please follow these steps: https://ui5.sap.com/#/topic/1b6dcd39a6a74f528b27ddb22f15af0d
Because a route could have multiple targets. This is the equivalent of the former subroutes.
By using multiple targets for a single route you can update different areas of your application at the same time resp. based on the same routing pattern.
Think of a SplitApp. If you want to change as well Master and Detail view based on routing you can define both of them as targets of the same route.
Find more info in the docs: https://sapui5.hana.ondemand.com/#/topic/b01840ec42ef48e6bfd2bc12612f501f

Creating a domain in Plesk's REST API

So, experimenting with Plesk's REST API (available as of version 17.8) for a project at work, and I'm starting to get a feel for it. I've been trying to experiment with adding a domain, but it's been giving me errors when I have to specify the hosting type.
The request body itself is as follows:
{
"name":"example.com",
"hosting_type":"virtual",
"description":"Description goes here"
}
This gets the following cryptic response:
{
"code": 1014,
"message": "htype\/vrt_hst is specified but there is no hosting\/vrt_hst"
}
Per the documentation provided at /api/v2/swagger.yml, any of the following values should be allowed: virtual, standard_forwarding, frame_forwarding, none
No matter what I put in, however, I get a variant of the response above (htype\/{type} is specified but there is no hosting\/{type}).
At this point I'm kind of stuck; I'm not sure what to check, and any references when I try to look up the error code go to references on Plesk's XML API instead. What's the missing link here needed to get the request to work?
It looks like system user is not specified - hosting_settings. Try to add domain with full json request. Here is example:
{
"name": "example.com",
"description": "My website",
"hosting_type": "virtual",
"hosting_settings": {
"ftp_login": "test_login",
"ftp_password": "test_pwd"
},
"base_domain": {
"id": 7,
"name": "a10-52-41-48.qa.plesk.ru",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"parent_domain": {
"id": 7,
"name": "a10-52-41-48.qa.plesk.ru",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"owner_client": {
"id": 7,
"login": "a10-52-41-48.qa.plesk.ru",
"guid": "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
"external_id": "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
},
"ipv4": [
"212.192.122.46"
],
"ipv6": [
"2002:5bcc:18fd:c:123:123:123:123"
],
"plan": {
"name": "Unlimited"
}
}
Examples for REST API https://app.swaggerhub.com/apis/plesk/api/v2#/Domains/post_domains