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"
}
]
Related
I am using Datastax Astra database. I am uploading csv file and I am setting all the columns data type as float, as per column. I connected with my db via python http_method.
res = astra_client.request(
method=http_methods.GET,
path=f"/api/rest/v2/keyspaces/{ASTRA_DB_KEYSPACE}/{ASTRA_DB_COLLECTION}/rows")
This gives me all the rows, but the data type is not maintained in the respond. All the float converted to string. Why and How can I solve this ?
{'PetalWidthCm': '0.2', 'Id': 23, 'PetalLengthCm': '1.0', 'SepalWidthCm': '3.6', 'Species': 'Iris-setosa', 'SepalLengthCm': '4.6'}
How are you creating your table and adding data? For example, the following works for me.
import http.client
import json
ASTRA_TOKEN = ""
ASTRA_DB_ID = ""
ASTRA_DB_REGION = ""
ASTRA_DB_KEYSPACE = "testks"
ASTRA_DB_COLLECTION = "float_test"
conn = http.client.HTTPSConnection(f"{ASTRA_DB_ID}-{ASTRA_DB_REGION}.apps.astra.datastax.com")
headers = {
'X-Cassandra-Token': ASTRA_TOKEN,
'Content-Type': 'application/json'
}
# Create the table
createTablePayload = json.dumps({
"name": f"{ASTRA_DB_COLLECTION}",
"columnDefinitions": [
{"name": "id", "typeDefinition": "text"},
{"name": "floatval", "typeDefinition": "float"},
{"name": "intval", "typeDefinition": "int"},
{"name": "doubleval", "typeDefinition": "double"}
],
"primaryKey": {"partitionKey": ["id"]},
"ifNotExists": True
})
# Add some data
conn.request("POST", f"/api/rest/v2/schemas/keyspaces/{ASTRA_DB_KEYSPACE}/tables", createTablePayload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
addRowPayload = json.dumps({
"id": "af2603d2-8c03-11eb-a03f-0ada685e0000",
"floatval": 1.1,
"intval": 2,
"doubleval": 3.3
})
conn.request("POST", f"/api/rest/v2/keyspaces/{ASTRA_DB_KEYSPACE}/{ASTRA_DB_COLLECTION}", addRowPayload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
# Read back the data
conn.request("GET", f"/api/rest/v2/keyspaces/{ASTRA_DB_KEYSPACE}/{ASTRA_DB_COLLECTION}/rows", "", headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
The response from this is
$ python3 get_rows.py
{"name":"float_test"}
{"id":"af2603d2-8c03-11eb-a03f-0ada685e0000"}
{"count":1,"data":[{"id":"af2603d2-8c03-11eb-a03f-0ada685e0000","doubleval":3.3,"intval":2,"floatval":1.1}]}
I am building a custom Power Query connector for Clio. It is my first PQ custom connector so I need to know 2 things:
How do I work in the token handling in the Token Handling section?
Once I get that working, how do I make the Client ID and Secret a dynamic reference to a separate file? I don't like the idea of hardcoding that into something.
Here is my code:
section Clio;
[DataSource.Kind="Clio", Publish="Clio.Publish"]
shared Clio.Contents = (optional message as text) =>
let
_message = if (message <> null) then message else "(no message)",
a = "Hello from Clio: " & _message
in
a;
OAuthBaseUrl = "https://app.clio.com/api/v4";
// Data Source Kind description
Clio = [
Authentication = [
OAuth = [
StartLogin = StartLogin,
FinishLogin = FinishLogin
]
],
Label = Extension.LoadString("DataSourceLabel")
];
// Data Source UI publishing description
Clio.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://powerbi.microsoft.com/",
SourceImage = Clio.Icons,
SourceTypeImage = Clio.Icons
];
StartLogin = (resourceUrl, state, display) =>
let
AuthorizeUrl = OAuthBaseUrl & "/oauth/authorize?" & Uri.BuildQueryString([
response_type = "code",
client_id = client_id_code,
redirect_uri = "https://app.clio.com/oauth/approval",
state = state
])
in
[
LoginUri = "https://app.clio.com",
CallbackUri = "https://app.clio.com/oauth/approval",
WindowHeight = 1080,
WindowWidth = 720
];
FinishLogin = (context, callbackUri, state) =>
let
Parts = Uri.Parts(callbackUri)[Query]
in
TokenMethod(Parts[code], "authorization_code", context);
//Token Handling
TokenMethod = (grant_type, optional verifier) =>
let
query = [
client_id = client_id_code,
client_secret = client_secret_code,
grant_type = "refresh_token",
refresh_token = I_don't_know_what_to_put_here
],
ManualHandlingStatusCodes= {400,403},
Response = Web.Contents(OAuthBaseUrl & "/token", [
Content = Text.ToBinary(Uri.BuildQueryString(query)),
Headers = [
#"Content-type" = "application/x-www-form-urlencoded",
#"Accept" = "application/json"
],
ManualStatusHandling = ManualHandlingStatusCodes
]),
Parts = Json.Document(Response)
in
// check for error in response
if (Parts[error]? <> null) then
error Error.Record(Parts[error], Parts[message]?)
else
Parts;
Refresh = (resourceUrl, refresh_token) => TokenMethod(refresh_token, "refresh_token");
Clio.Icons = [
Icon16 = { Extension.Contents("Clio16.png"), Extension.Contents("Clio20.png"), Extension.Contents("Clio24.png"), Extension.Contents("Clio32.png") },
Icon32 = { Extension.Contents("Clio32.png"), Extension.Contents("Clio40.png"), Extension.Contents("Clio48.png"), Extension.Contents("Clio64.png") }
];
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" : ""
}
]
}
}
}
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.
Please help me on writing a check using the QuickBooks online(Qbo) API. I tried to do that but i'm always getting an error saying "Error validating Detail Lines:At least one detail line is required." Sample Code is in Below.. How should I add Lines for Checks.
Dim existingChk = New Qbo.Check()
Dim existingChks = commonService.FindAll(existingChk, 1, 10).ToList()
Dim payment = New Qbo.Payment()
Dim payments = commonService.FindAll(payment, 1, 10).ToList()
Dim qboCheck = New Intuit.Ipp.Data.Qbo.CheckHeader()
Dim bank = New Intuit.Ipp.Data.Qbo.Account()
bank.Type = Intuit.Ipp.Data.Qbo.AccountTypeEnum.Asset
Dim Banks = commonService.FindAll(bank, 1, 100).ToList()
Dim accountId As New Qbo.IdType
For Each bnk As Intuit.Ipp.Data.Qbo.Account In Banks
If bnk.Name = "Test Bank" Then
accountId = bnk.Id
End If
Next
qboCheck.BankAccountId = accountId
qboCheck.BankAccountName = "Test Bank"
qboCheck.TotalAmt = 20.0
qboCheck.Currency = Intuit.Ipp.Data.Qbo.currencyCode.USD
qboCheck.TxnId = payments(0).Id
Dim qboCustomer = New Intuit.Ipp.Data.Qbo.Customer()
Dim qboCustomers = commonService.FindAll(qboCustomer, 1, 10).ToList()
For Each cus As Intuit.Ipp.Data.Qbo.Customer In qboCustomers
If cus.Name.Contains("Customer1") Then
qboCheck.EntityId = cus.Id
End If
Next
qboCheck.EntityType = Qbo.EntityTypeEnum.Customer
Dim check = New Intuit.Ipp.Data.Qbo.Check()
check.Header = qboCheck
check.Id = New Qbo.IdType
check.Id.idDomain = existingChks(0).Id.idDomain
check.Id.Value = CInt(existingChks(0).Id.Value) + 1
Dim resultCheck As Qbo.Check = TryCast(commonService.Add(check), Qbo.Check)
Looks like it is a bug in .net devkit(I'm not 100% sure).
JavaDocs says accountId and itemId both are inherited from LinePurchase(PFB snapshot). But in .net devkit, I don't see those fields neither in LinePurchase nor in LineBase.
JavaDoc Ref - http://developer-static.intuit.com/SDKDocs/QBV2Doc/ipp-java-devkit-2.0.10-SNAPSHOT-javadoc/
API endpoints are working fine.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/check#Sample_Create_Request_XML
<?xml version="1.0" encoding="utf-8" ?>
<Check xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
<Header>
<TxnDate>2013-08-09</TxnDate>
<BankAccountId>44</BankAccountId>
<EntityId>2</EntityId>
</Header>
<Line>
<Desc>Hard Disks</Desc>
<Amount>500</Amount>
<BillableStatus>NotBillable</BillableStatus>
<ItemId>4</ItemId>
<Qty>10</Qty>
<UnitPrice>50</UnitPrice>
</Line>
</Check>
PN -
<BankAccountId> : This account should be a 'checking' type.
<ItemId> : Item should have a 'ExpenseAccountRef' tag.
You can test this usecase, using ApiExplorer tool.
Link - https://developer.intuit.com/apiexplorer?apiname=V2QBO
If possible I'll try this using .net devkit on monday and confirm if it is a bug in .net devkit.
Thanks
Adding pseudo code for c# for BillpaymentHeader.
Similarly you can use it for CheckLine:
billheader.ItemsElementName = new ItemsChoiceType[1];
billheader.ItemsElementName[0] = ItemsChoiceType.BankAccountId;
billheader.Items = new object[1];
billheader.Items[0] = new Intuit.Ipp.Data.Qbo.IdType() { idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO, Value = "1" };
Refer- How to add AccountID or ItemID when creating Checks in QuickBooks
If you have bill already then you can simply use billpayment API to create checks.
URL : https://quickbooks.api.intuit.com/v3/company/111111111111/billpayment?minorversion=4
request JSON data:
{
"VendorRef": {
"value": "1",
"name": "vendor_name"
},
"PayType": "Check",
"CheckPayment": {
"BankAccountRef": {
"value": "1",
"name": "Test Account"
}
},
"TotalAmt": 100.00,
"PrivateNote": "Acct. 1JK90",
"Line": [
{
"Amount": 100.00,
"LinkedTxn": [
{
"TxnId": "1",
"TxnType": "Bill"
}
]
}
]
}