Consuming SalesOrderItem API using S/4HANA SDK - s4sdk

I am trying to get all SalesOrderItems using the
com.sap.cloud.sdk.s4hana.datamodel.odata.services.DefaultSalesOrderService
class provided by S/4HANA SDK but the response is always an empty list and in logs I see this error:
c.s.c.s.odatav2.connectivity.ODataQuery : Failed to convert response into ODataFeed: Illegal argument for method call with message 'to_ValueAddedService'.
Mention: The latest version of the SDK is used - 2.9.1 - and the version of the S/4HANA system is 1902.
This is a response example:
{
"d":{
"results":[
{
"__metadata":{
"id":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')",
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')",
"type":"API_SALES_ORDER_SRV.A_SalesOrderItemType"
},
"SalesOrder":"1",
"SalesOrderItem":"10",
"HigherLevelItem":"0",
"SalesOrderItemCategory":"",
"SalesOrderItemText":"Trading Goods Testing",
"PurchaseOrderByCustomer":"test 1",
"Material":"HAWA1",
"MaterialByCustomer":"",
"PricingDate":"\/Date(1547769600000)\/",
"RequestedQuantity":"10",
"RequestedQuantityUnit":"PC",
"ItemGrossWeight":"1.000",
"ItemNetWeight":"1.000",
"ItemWeightUnit":"KG",
"ItemVolume":"0.000",
"ItemVolumeUnit":"",
"TransactionCurrency":"",
"NetAmount":"1000000",
"MaterialGroup":"A001",
"MaterialPricingGroup":"",
"Batch":"",
"ProductionPlant":"",
"StorageLocation":"",
"DeliveryGroup":"0",
"ShippingPoint":"",
"ShippingType":"",
"DeliveryPriority":"1",
"IncotermsClassification":"",
"IncotermsTransferLocation":"",
"IncotermsLocation1":"",
"IncotermsLocation2":"",
"CustomerPaymentTerms":"",
"SalesDocumentRjcnReason":"",
"ItemBillingBlockReason":"",
"WBSElement":"",
"ProfitCenter":"",
"ReferenceSDDocument":"",
"ReferenceSDDocumentItem":"0",
"SDProcessStatus":"A",
"DeliveryStatus":"A",
"OrderRelatedBillingStatus":"",
"YY1_DownPaymentReferen_SDI":"1400000013",
"to_Partner":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_Partner"
}
},
"to_PricingElement":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_PricingElement"
}
},
"to_SalesOrder":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_SalesOrder"
}
},
"to_ScheduleLine":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_ScheduleLine"
}
},
"to_Text":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_Text"
}
},
"to_ValueAddedService":{
"__deferred":{
"uri":"/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrderItem(SalesOrder='1',SalesOrderItem='10')/to_ValueAddedService"
}
}
}
]
}
}

It is an issue with the Sales Order API on SAP S/4HANA Cloud side. The to_ValueAddedService navigational property is not declared in the $metadata, however it appears on the A_SalesOrderItem OData EDM Entity and is not working. SAP S/4HANA Cloud colleagues are already looking into the incident.

Using .select() before executing the request bypasses this issue but this is not a long term solution. This needs to be fixed internally in the SDK.

Related

google-api-nodejs-client - Service Account credentials authentication issues

I am trying to use the google-api-nodejs library to manage some resources in the google Campaign Manager API.
I have confirmed that we currently have a project configured, and that this project has the google Campaign Manager API enabled (see screenshot at the bottom).
I have tried several ways of authenticating myself (particularly API keys, OAuth2, and Service account credentials). This question will focus on using a Service Account for authentication purposes.
Now, I have generated a new service account keyfile (see screenshot at the bottom)), and I configured my code as follows, following the service-account-credentials section of the library's repo. I've also extended the auth scope to include the necessary scope according to this endpoint API docs
import { assert } from "chai";
import { google } from "googleapis";
it("can query userProfiles using service account keyfile", async () => {
try {
const auth = new google.auth.GoogleAuth({
keyFile:
"/full-path-to/credentials-service-account.json",
scopes: [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/dfatrafficking",
"https://www.googleapis.com/auth/ddmconversions",
"https://www.googleapis.com/auth/dfareporting",
],
});
const authClient = await auth.getClient();
// set auth as a global default
google.options({
auth: authClient,
});
const df = google.dfareporting("v3.5");
const res = await df.userProfiles.list({});
console.log("res: ", res);
assert(true);
} catch (e) {
console.error("error: ", e);
assert(false);
}
});
This results in the following error:
{
"code": 403,
"errors": [
{
"message": "Version v3.5 is no longer supported. Please upgrade to the latest version of the API.",
"domain": "global",
"reason": "forbidden"
}
]
}
This is an interesting error, because v3.5 is the latest version of that API (as of 14 April 2022) (This page shows the deprecation schedule: https://developers.google.com/doubleclick-advertisers/deprecation. Notice that v3.3 and v3.4 are deprecated, while v3.5 is not.)
In any case, using a different version of the dfareporting API still result in error:
// error thrown: "Version v3.5 is no longer supported. Please upgrade to the latest version of the API."
const df = google.dfareporting("v3.5");
// error thrown: "Version v3.4 is no longer supported. Please upgrade to the latest version of the API."
const df = google.dfareporting("v3.4");
// error thrown: 404 "The requested URL <code>/dfareporting/v3.3/userprofiles</code> was not found on this server"
const df = google.dfareporting("v3.3");
// Note 1: There are no other versions available
// Note 2: It is not possible to leave the version blank
const df = google.dfareporting();
// results in typescript error: "An argument for 'version' was not provided."
I also tried to query the floodlightActivities API, which failed with an authentication error.
// const res = await df.userProfiles.list({});
const res = await df.floodlightActivities.list({
profileId: "7474579",
});
This, in it's turn, results in the following error:
{
"code": 401,
"errors": [
{
"message": "1075 : Failed to authenticate. Google account can not access the user profile/account requested.",
"domain": "global",
"reason": "authError",
"location": "Authorization",
"locationType": "header"
}
]
}
Now, my question is:
am I doing something wrong while trying to authenticate using the service account credentials?
Or, is it possible that these endpoints do not support service-account-credentials?
Or, is something else going wrong here?

Bot framework SDK NodeJS and Custom Question Answering: Failed to generate answers: [object Object]

After an upgrade of one of my knowledgebases from QnaMaker to a language resource with custom question answering enable (FKA QnAMaker Managed), my chatbot does not function anymore and returns an error: DialogContextError: Failed to generate answers: [object Object]
My .env has:
QnAKnowledgebaseId=<name of my knowledgebase>
QnAEndpointKey=<the Ocp-Apim-Subscription-Key from the prediction url
QnAEndpointHostName=https://<languageresourcename>.cognitiveservices.azure.com/ (I also tried to add language/ to the url)
QnaMaker initialization:
const { QnAMaker } = require('botbuilder-ai');
try {
this.qnaMaker = new QnAMaker({
knowledgeBaseId: process.env.QnAKnowledgebaseId,
endpointKey: process.env.QnAEndpointKey,
host: process.env.QnAEndpointHostName
});
} catch (err) {
console.warn(`QnAMaker Exception: ${ err } Check your QnAMaker configuration in .env`);
}
And called by:
const qnaResults = await this.qnaMaker.getAnswers(step.context);
dependencies:
"dependencies": {
"adaptivecards-templating": "^1.4.0",
"applicationinsights": "^1.8.10",
"azure-storage": "^2.10.5",
"body-parser": "^1.19.0",
"botbuilder": "^4.15.0",
"botbuilder-ai": "^4.15.0",
"botbuilder-azure-blobs": "4.14.1-preview",
"botbuilder-dialogs": "^4.15.0",
"botbuilder-lg": "^4.15.0",
"botframework-config": "^4.11.2",
...
}
Using the key, knowledgebaseid and hostname from my old QnAMaker KB works just fine. Struggling to translate the new prediction url into an object for the QnAMaker.
Update
The class GenerateAnswerUtils (called by QnaMaker) is expecting the following:
const url = `${endpoint.host}/knowledgebases/${endpoint.knowledgeBaseId}/generateanswer`;
This will not work with a QnaMaker KB migrated to Custom Questions which expects an url like this:
'https://<languageresourcename>.cognitiveservices.azure.com/language/:query-knowledgebases?projectName=<projectname>&api-version=2021-10-01&deploymentName=production'
Not sure if this should be a bugreport or feature request. I will file an issue anyway.
The BotFramework SDK does not support the new Custom Questions feature yet. This was causing the error. A feature request is already filed.

JSON parse error: Can not set com.google.api.services.androidmanagement.v1.model.KioskCustomization field

Issue while creating Policy In Android Management API,Iam Using Spring Boot as BackEnd.
this is my request:
{
"name": "testpolicy",
"applications": [
{
"packageName": "com.adobe.reader",
"installType": "REQUIRED_FOR_SETUP",
"defaultPermissionPolicy": "GRANT"
}
],
"kioskCustomization":{
"powerButtonActions": "POWER_BUTTON_ACTIONS_UNSPECIFIED",
"systemErrorWarnings": "SYSTEM_ERROR_WARNINGS_UNSPECIFIED",
"systemNavigation": "SYSTEM_NAVIGATION_UNSPECIFIED",
"statusBar": "STATUS_BAR_UNSPECIFIED",
"deviceSettings": "DEVICE_SETTINGS_UNSPECIFIED"
},
"kioskCustomLauncherEnabled": true
}
This is my response:
JSON parse error: Can not set com.google.api.services.androidmanagement.v1.model.KioskCustomization field com.google.api.services.androidmanagement.v1.model.Policy.kioskCustomization to java.util.LinkedHashMap; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not set com.google.api.services.androidmanagement.v1.model.KioskCustomization field com.google.api.services.androidmanagement.v1.model.Policy.kioskCustomization to java.util.LinkedHashMap (through reference chain: com.google.api.services.androidmanagement.v1.model.Policy["kioskCustomization"])
code written in the controller:
#PostMapping("/policies")
public ResponseEntity<com.google.api.services.androidmanagement.v1.model.Policy> savePolicy(
#RequestBody Policy policy, #RequestParam String enterpriseId) throws Exception {
}
control is not even coming inside the controller
I tried your request in Quickstart and did not encounter any error, the cause of your error may come from your implementation (Parser being used, or the format when typed) , I suggest that you try your request in quickstart to confirm that there is nothing wrong with your request.
Also you can check this documentation for a sample app that demonstrates how to provision a corporate-owned, single-use (COSU) device, and send it a reboot command. The app uses the Android Management API Java client library.

Whats the right BlobStorageService Configuration format?

When creating a Microsoft Bot Framework 4 project - the Startup.cs has the following code which can be uncommented.
const string StorageConfigurationId = "<NAME OR ID>";
var blobConfig = botConfig.FindServiceByNameOrId(StorageConfigurationId);
if (!(blobConfig is BlobStorageService blobStorageConfig))
{
throw new InvalidOperationException($"The .bot file does not contain an blob storage with name '{StorageConfigurationId}'.");
}
This code handles a way to configure an Azure Storage Account via Json Configuration.
However the project lacks an example on what the config Json looks like for the "is BlobStorageService" to work.
I have done various tries and searched for examples but cannot make it work.
Has anyone got the nailed?
Got it working using this json...
{
"type": "blob", //Must be 'blob'
"name": "<NAME OF CONFIG - MUST BE UNIQUE (CAN BE ID)>",
"connectionString": "<COPY FROM AZURE DASHBOARD>",
"container": "<NAME OF CONTAINER IN STORAGE>"
}

Failure connecting to S/4 Hana via Cloud SDK

I'm following the OData tutorial at https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/comment-page-1/ and I'm getting an error when I try to retrieve business partners using DefaultBusinessPartnerService.
The relevant piece of code is:
DefaultBusinessPartnerService businessPartnerService = new DefaultBusinessPartnerService();
System.err.println("criated default business partner");
List<BusinessPartner> partners = businessPartnerService
.getAllBusinessPartner()
.select(BusinessPartner.BUSINESS_PARTNER,
BusinessPartner.LAST_NAME,
BusinessPartner.FIRST_NAME)
//.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_VENDOR))
.orderBy(BusinessPartner.LAST_NAME, Order.ASC)
.execute(new ErpEndpoint(new ErpConfigContext()));
response.setContentType("application/json");
response.getWriter().write(new Gson().toJson(partners));
My ErpQueryEndpoint configuration is as follows:
#Mon May 14 15:27:09 BRT 2018
URL=https\://host\:port
Name=ErpQueryEndpoint
TrustAll=TRUE
Type=HTTP
Password=Password
Authentication=BasicAuthentication
User=Username
Where host, port, Username and Password have been replaced by the correct values.
When I query http://localhost:8080/s4integration-application/businesspartners I get the following error:
The endpoint responded with HTTP error code 403.
No service found for namespace , name API_BUSINESS_PARTNER, version 0001
Full error message:
{
"error": {
"code": "/IWFND/MED/170",
"message": {
"lang": "en",
"value": "No service found for namespace , name API_BUSINESS_PARTNER, version 0001"
},
"innererror": {
"application": {
"component_id": "",
"service_namespace": "/SAP/",
"service_id": "API_BUSINESS_PARTNER",
"service_version": "0001"
},
"transactionid": "C83CB3D2A1420000E005AF97B0836AD5",
"timestamp": "20180514182746.3576100",
"Error_Resolution": {
"SAP_Transaction": "Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system (System Alias ) and search for entries with the timestamp above for more details",
"SAP_Note": "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
},
"errordetails": []
}
}
}
It seems that the endpoint is not configured on the SAP system (it's an S/4 Hana system). I'm not sure if I have to add something else to the URL besides the host and port or if there is some other configuration that has to be done on the SAP system.
Instructions for activating OData APIs from the SAP S/4HANA backend can be found here: help.sap.com/viewer/cdc25c83b63e482586b31b8acd49cf2f/1610%20003/… Just ignore the notion of the Fiori app.

Resources