Can i change in the OData errorhandling the errordetails property? - odata

is there a way to change in the /IWBEP/CX_MGW_BUSI_EXCEPTION the errordetails the property code? Like write my own stuff in there
For Example

Raise /iwbep/cx_mgw_busi_exception with custom message
DATA lr_busi_exception TYPE REF TO /iwbep/cx_mgw_busi_exception.
DATA lr_mcontainer TYPE REF TO /iwbep/if_message_container.
DATA lv_message_text TYPE bapi_msg.
DATA lv_message_attr1 TYPE symsgv.
DATA lv_message_attr2 TYPE symsgv.
DATA lv_message_attr3 TYPE symsgv.
DATA lv_message_attr4 TYPE symsgv.
CREATE OBJECT lr_busi_exception.
CALL METHOD lr_busi_exception->get_msg_container
RECEIVING
ro_message_container = lr_mcontainer.
lv_message_text = 'Error'.
lv_message_attr1 = ''.
lv_message_attr2 = ''.
lv_message_attr3 = ''.
lv_message_attr4 = ''.
lr_mcontainer->add_message(
EXPORTING
iv_msg_type = 'E'
iv_msg_id = 'MY_CUSTOM_CODE'
iv_msg_number = 001
iv_msg_text = lv_message_text
iv_msg_v1 = lv_message_attr1
iv_msg_v2 = lv_message_attr2
iv_msg_v3 = lv_message_attr3
iv_msg_v4 = lv_message_attr4
).
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message_container = lr_mcontainer.
Result:
{
"error" : {
"code" : "MY_CUSTOM_CODE/001",
"message" : {
"lang" : "de",
"value" : "Error"
},
"innererror" : {
"application" : {
"component_id" : "",
"service_namespace" : "/XXX/",
"service_id" : "XXX_SRV",
"service_version" : "0001"
},
"transactionid" : "XXXXXXXXXXXXXXXXXXXX",
"timestamp" : "XXXXXXXXXXXXXXXXXXXXXXXXX",
"Error_Resolution" : {
"SAP_Transaction" : "For backend administrators: use ADT feed reader \"SAP Gateway Error Log\" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system 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" : [
{
"code" : "MY_CUSTOM_CODE/001",
"message" : "Error",
"propertyref" : "",
"severity" : "error",
"transition" : false,
"target" : ""
}
]
}
}
}

Related

Why am I getting formula parse error from my custom function?

Hi I am using a custom function to format urls in google sheets:
/*
* Formats the page urls
*/
function URLS(page_url_list){
const urls = [];
for(let i = 0; i < page_url_list.pages.length; i++){
urls.push(page_url_list.pages[i].page_url + "\n");
}
return urls;
}
When I try to use it in google sheets
=URLS({
"pages" : [
{
"id" : 0,
"page_url" : "..."
}
]
})
I am getting a formula parse error
Object is not supported by formula, you may need to change it into a JSON string and then do JSON.parse in your function.
=URLS("{
""pages"" : [
{
""id"" : 0,
""page_url"" : ""...""
}
]
}")
or
=URLS("{
'pages' : [
{
'id' : 0,
'page_url' : '...'
}
]
}")
and replace ' with " in you function before doing JSON.parse.

Form data is not correct with Suave web server

I am trying to receive a confirmation from AWS' SNS system.
It sends a message through a POST to a webserver and I'm receiving it using Suave.
When I get the message, the form field is truncated, I am receiving:
"{\n \"Type\" : \"SubscriptionConfirmation\",\n \"MessageId\" : \"13dd68fa-2720-419a-8d8a-edc9f4466ea3\",\n \"Token\" : \"2336412f37fb687f5d51e6e2425e90ccf23f36200405c1942ea85f0874b382c47327c4bfd63203eace5240bb7b253428af362a04a61c8f98ab1718c679e9e27594529615adf5d86729374cce472768b91622851aced957c1dcddf21e3d82b48f5ff528c8dbc911179a3f26126a8d7f00\",\n \"TopicArn\" : \"arn:aws:sns:ap-northeast-1:960544703730:igorbot\",\n \"Message\" : \"You have chosen to subscribe to the topic arn:aws:sns:ap-northeast-1:960544703730:igorbot.\\nTo confirm the subscription, visit the SubscribeURL included in this message.\",\n \"SubscribeURL\" : \"https://sns.ap-northeast-1.amazonaws.com/?Action",
"ConfirmSubscription"
so it's an unfinished json...
but when I look at the rawForm field, I get the whole message:
{
"Type" : "SubscriptionConfirmation",
"MessageId" : "0645c009-f4fa-4fb7-9c94-127e98f5eb76",
"Token" : "2336412f37fb687f5d51e6e2425e90ccf23f36200406641a9f63b753dad1d31c61da2ebeea8cdaeed2e3c04f701bd08e2d2c9cac65676979e43c1089a96779f9b57a0e0f072013333db51472ca43c1e6a0854cf3af6769d95c7911d74c9e2bec22db93de90e537d480070891ddaaa548",
"TopicArn" : "arn:aws:sns:ap-northeast-1:960544703730:igorbot",
"Message" : "You have chosen to subscribe to the topic arn:aws:sns:ap-northeast-1:960544703730:igorbot.\nTo confirm the subscription, visit the SubscribeURL included in this message.",
"SubscribeURL" : "https://sns.ap-northeast-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:ap-northeast-1:960544703730:igorbot&Token=2336412f37fb687f5d51e6e2425e90ccf23f36200406641a9f63b753dad1d31c61da2ebeea8cdaeed2e3c04f701bd08e2d2c9cac65676979e43c1089a96779f9b57a0e0f072013333db51472ca43c1e6a0854cf3af6769d95c7911d74c9e2bec22db93de90e537d480070891ddaaa548",
"Timestamp" : "2021-03-13T20:36:21.918Z",
"SignatureVersion" : "1",
"Signature" : "FBnpuGtkZmzox+5ryo1/4k1hgwmoeuvcptQ2dOyyneShVHovmdemMqo9JFTzbBFelTN7FMojX/sIjFs2dZoQYeqEgsQW9WqCiEstDQu0toHn7KKxapzIoGfjfh6Rikfy8Liv88RRNLC2DLtxWW2JWr5Mmwkjtro/pm7vyJhfp5G4qcAB3gtBOtVm+XOAai6rY7obcMojkmMr4jDd9UqutV6imyYDCH+PvUCnc7aKg6p4EmZO33VlRibIPa5PiN1Sj/mmNhyoeR4pGu+0Jci+utvonXaYPgtlDuEyoVcgUQ6lki1xiclIRpDm4FvOL5tvUSq+Jdjz3prlNDNM8AuQpQ==",
"SigningCertURL" : "https://sns.ap-northeast-1.amazonaws.com/SimpleNotificationService-010a507c1833636cd94bdb98bd93083a.pem"
}
At first I thought the output was truncated, but then I narrowed it down. Posting this line:
{
"SubscribeURL" : "https://sns.ap-northeast-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:ap-northeast-1:960544703730:igorbot&Token=2336412f37fb687f5d51e6e2425e90ccf23f36200406641a9f63b753dad1d31c61da2ebeea8cdaeed2e3c04f701bd08e2d2c9cac65676979e43c1089a96779f9b57a0e0f072013333db51472ca43c1e6a0854cf3af6769d95c7911d74c9e2bec22db93de90e537d480070891ddaaa548"
}
will fail and get truncated at the first '=' sign. Then:
{
"SubscribeURL" : "abc=3"
}
will cause Suave to fail. When sent as form data, it will not be converted to a string properly.
Is there any setting related to encoding, etc that would allow to prevent this? (since I can't ask AWS to escape all their '=' signs)
JSON and form data (application/x-www-form-urlencoded, to be specific) have different syntax. Form data looks like key1=value1&key2=value2, so Suave is breaking the string on & and = in order to parse it.
You can parse JSON using mapJson instead. Something like this should work:
open System.Runtime.Serialization
open Suave
open Suave.Json
[<DataContract>]
type Subscription =
{
[<field: DataMember(Name = "SubscribeURL")>]
SubscribeUrl : string;
}
[<EntryPoint>]
let main argv =
let app = mapJson (fun sub -> sprintf "URL: %s" sub.SubscribeUrl)
startWebServer defaultConfig app
0

what is the output type in bazel?

In Bazel you can define an attribute type, which could be int or string ... or output
What does it mean to have a type of attribute as "output" ?
Here's an example:
def _something(ctx):
print("The username is: ", ctx.attr.username)
print("boolean value is", ctx.attr.boolean)
print("my age is:", ctx.attr.age)
print("Start printing hours .." )
for i in ctx.attr.hours:
print (i)
print("Finish printing hours ..")
print("Depending on: ", ctx.attr.dep_on)
print_me = rule(
implementation = _something,
attrs = {
"username" : attr.string(),
"boolean" : attr.bool(),
"age" : attr.int(),
"hours" : attr.int_list(),
"dep_on": attr.label(),
"the_results": attr.output(),
},
)
It's a simple rule, which has the_results as of type output
It means that attribute corresponds to a file that the rule will create an action to produce. See https://docs.bazel.build/versions/master/skylark/rules.html#output-attributes and https://docs.bazel.build/versions/master/skylark/lib/attr.html#output.

Metric math alarms: How can I use a for_each expression to loop over metrics within a dynamic block?

I am trying to create dynamic metric math alarms, that are configurable with a JSON.
I am struggling with looping over the metric alarm with a for_each expression as this is a loop within a loop.
Here is an example of what I am trying to do:
resource "aws_cloudwatch_metric_alarm" "Percentage_Alert" {
for_each = var.percentage_error_details
locals { alarm_details = each.value }
alarm_name = "${terraform.workspace}-${each.key}"
comparison_operator = local.alarm_details["Comparison_Operator"]
evaluation_periods = "1"
threshold = local.alarm_details["Threshold"]
metric_query {
id = "e1"
expression = local.alarm_details["Expression"]
label = local.alarm_details["Label"]
return_data = "true"
}
dynamic "metric_query" {
for metric in each.value["Metrics"]{
id = metric.key
metric_name = metric.value
period = local.alarm_details["Period"]
stat = local.alarm_details["Statistic"]
namespace = local.full_namespace
unit = "Count"
}
}
}
And this is the sample JSON
{
"locals": {
"Name": {
"Name": "metric_math",
"Metrics": {
"m1": "Sucess",
"m2": "Failure"
},
"Expression": "100*(m2/(m1+m2))",
"Threshold" : 1,
"Period": 25,
"Priority": "critical",
"Statistic": "Sum",
"Label": "label",
"Comparison_Operator": "GreaterThanOrEqualToThreshold"
}
}
}
And this is the error message i'm getting:
Error: Invalid block definition
On ../modules/cloudwatch/metriclogfilter/main.tf line 89: Either a quoted
string block label or an opening brace ("{") is expected here.
Any help would be much appreciated.

how to set custom example in #ApiResponse in swagger [duplicate]

I am facing issue with example in response.
#ApiResponse(code=200,
message="fetch list of Service/Config Resources",
response = testing.class,
responseContainer = "List",
examples=#Example(
value = #ExampleProperty(
mediaType = MediaType.APPLICATION_JSON_VALUE,
value = "{testingId: 1234, testingName = Testing Name}"
)
)
)
But getting response example as
[
{
"testingId": "string",
"testingName": "string"
}
]

Resources