API Odata OR or IN operator - acumatica

version 22 R1
Is there any way to make a logical OR query to the contract-based API? As far as I can tell it's not possible but, I wanted to check with the community. So, a filter like this:
/Default/20.200.001/salesorder?$filter=OrderNbr eq 'SO006538' or OrderNbr eq 'SO006537'
is coming back with a HTTP 500 response "Only AND logical operator is supported".
I also tried this, which is coming back with a syntax error:
/Default/20.200.001/salesorder?$filter=OrderNbr in ('SO006537','SO006538')
TIA!

try ( )
....$filter=(OrderNbr eq 'SO006538') or (OrderNbr eq 'SO006537')
example:
http://services.odata.org/v4/TripPinServiceRW/People?$filter=(FirstName eq 'Ronald') or (FirstName eq 'Russell')

The 'or' has been implemented only from Acumatica 2022R2.
It is detailed in the section "Web Services: Innovations in the Implementation of the
REST API" of the developer release notes available here
https://community.acumatica.com/supported-releases-67/acumatica-2022-r2-downloads-and-release-notes-11493
The 'in' is not yet available.

Related

azure amortized cost usagestart and usageend date error while passing it as variable

I am trying to pull azure amortized cost at subscription level but when I pass usage_start_date and usage_end_date in hardcoded way I am able to pull data :
Example : "https://management.azure.com/subscriptions/"+subs+"/providers/Microsoft.Consumption/usageDetail?$filter=properties/usageStart eq '2022-05-01' and properties/usageEnd eq '2022-05-31'&metric=AmortizedCost&api-version=2021-10-01"
But when I am passing start usage and start end date as variable it is throwing error.
API example:
f"https://management.azure.com/subscriptions/{subs}/providers/Microsoft.Consumption/usageDetails?$filter=properties/usageStart eq {start_date} and properties/usageEnd eq {end_date}&metric=AmortizedCost&api-version=2021-10-01"
like :
'message': 'Billing Period is not supported in (2019-10-01) API Version for Subscription Scope With Web Direct Offer. Please provide the UsageStart and UsageEnd dates in the $filter key as parameters.'}}
{'error': {'code': '400',
'message': 'Billing Period is not supported in (2021-10-01) API Version for Subscription Scope With Web Direct Offer. Please provide the UsageStart and UsageEnd dates in the $filter key as parameters. (Request ID: f2d9517e-e438-42b3-865e-df2d5888da62)'}}
I have tried many option/combination to pull data by passing date range variable it gave me same error.
I have tried API from this link as well:
https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/manage-automation#get-usage-details-for-a-scope-during-specific-date-range
Can you please guide me what I am doing wrong. How can I fix this issue?
Finally this help me
not working:
costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq {end_date} and properties/usageStart eq {start_date}")
working:
costmanagement_client.usage_details.list( scope=f'/subscriptions/{subscription_id}/', filter=f"properties/usageEnd eq '{end_date}' and properties/usageStart eq '{start_date}'")
just put in quote
You need to include the time along with date
properties/usageStart eq '2022-07-01T00:00:00.0000000Z' and properties/usageEnd eq '2022-07-31T23:59:59.0000000Z'
try this

odata query fails with Power BI - OData: The property 'PassedPct' does not exist on type 'Microsoft.VisualStudio.Services.Analytics.Model.TestPoint'

I'm attempting to use odata to make a connection from Azure Devops to Power BI. I was successful in first attempts. Now I have been running into this error.
Details: "OData: The property 'PassedPct' does not exist on type 'Microsoft.VisualStudio.Services.Analytics.Model.TestPoint'. Make sure to only use property names that are defined by the type or mark the type as open type."
I would be happy the mark my computed vars as 'open type' but have not found too much about how to do this in my query (query below)
Actaully when I remove the PassedPct field - the query will now fail on one of the fields in the aggregate section.
I have been following this tutorial
Progress status sample report
https://learn.microsoft.com/en-us/azure/devops/report/powerbi/sample-test-plans-progress-status?view=azure-devops&tabs=odata
Below is the odata query I am using:
https://analytics.dev.azure.com/UCareTFSAzureDevOps/Dev/_odata/v3.0-preview/TestPoints?
$apply=filter(
(TestSuite/TestPlanTitle eq 'macgowan_test')
)
/aggregate(
$count as TotalCount,
cast(LastResultOutcome eq 'Passed', Edm.Int32) with sum as Passed,
cast(LastResultOutcome eq 'Failed', Edm.Int32) with sum as Failed,
cast(LastResultOutcome eq 'Blocked', Edm.Int32) with sum as Blocked,
cast(LastResultOutcome eq 'NotApplicable', Edm.Int32) with sum as NotApplicable,
cast(LastResultOutcome eq 'None', Edm.Int32) with sum as NotExecuted,
cast(LastResultOutcome ne 'None', Edm.Int32) with sum as Executed
)
/compute(
Executed mul 100 div TotalCount as ExecPct,
iif(TotalCount gt NotExecuted, Passed mul 100 div Executed,0) as PassedPct
)
Note that per the tutorial the Azure instance (UCareTFSAzureDevOps), project (Dev) and Test Suite (macgowan_test) are all configurable in the URL.
Below are some scene shots for reference:
Azure Devops
odata query (in Visual Studio Code - using odata extension to execute)
odata query output from Visual Studio Code (it works)
Adding odata query URL to Power BI odata feed option
URL is encoded by Visual Studio Code and odata extension
The Happy Error Message :-
Any help is appreciated -
Thanks,
Chris

Return response according to a common json schema

How can I make standard json keys schema for multiple API service.
What if on original response I want to map to specific keys?
Maybe adding or removing keys too?
I'd like to have same json keys output for all api services
for example: api service output:
{ "hello" : "word" }
but i want to response:
{"foo" : originalResponse.hello }
Thanks
I do not understand why the downvotes, the question seems legit to me.
In any case, you can achieve the use case by using the body modifier plugin we offer. Although it's not an official one, it should provide all you need to both add are move keys on a JSON payload based on any Javascript evaluable expression.
Cheers!

Correct parameters for RateCard API

I am trying to fetch the RateCards for my Azure subscription, however I am unable to figure out the correct (combination of) parameters for my call to the API. I keep getting the following message:
{
"Message": "Invalid query specified. Please specify valid values for OfferDurableId, Currency, Locale and RegionInfo."
}
I'm currently supplying the following parameters:
$filter=OfferDurableId eq ’MS-AZR-0003P’ and Currency eq ’EUR’ and Locale eq ’en-US’ and RegionInfo eq ’NL’
I'm not certain whether there are any requirements between the OfferDurableId, Currency and Locale parameters, but I think these are fine. The parameter I'm mostly confused about is RegionInfo. As per the documentation (whatever little there is), this is the 2-letter ISO code which represents the country in which I purchased my subscription. I am quite certain that this was bought in the Netherlands, hence my attempt with NL, but it doesn't work. I've tried IE, GB, US and some neighbouring countries, but none of them work.
I should mention, the example in the docs (MS-AZR-0003P, USD, en-US and US) doesn't work for my subscription either, I'm guessing due to a mismatch in RegionInfo.
What would be a correct combination of values? Where would I find these values? (e.g. where would I find RegionInfo?)
As per #GauravMantri's response, the issue was indeed in the quotes. The "weird backquotes" (which were copied straight from Microsoft's documentation itself) are the issue. When replaced with normal single quotes (and after url-encoding the $filter value), the query works and returns my rate cards.

Servicestack OrmLite "where exists" subquery

No matter how hard I tried I couldn't make it work and I'm not sure if it is possible.
I want to select all clients who have at least one order.
The first thing I tried was db.Exists as following:
SqlExpression<Client> exp = OrmLiteConfig.DialectProvider.SqlExpression<Client>();
exp.Where(x => Db.Exists<Order>(z => z.ClientId == x.Id));
but I get the following error
variable 'x' of type '[assembly].Client' referenced from scope '', but it is not defined`
Second try was using Join and SelectDistinct:
SqlExpression<Client> exp = OrmLiteConfig.DialectProvider.SqlExpression<Client>();
ev.Join<Client, Order>((b, a) => b.Id == a.ClientId)
.SelectDistinct(x => new { x.Id, x.ClientNumber, x.ClientNameName});
Although not optimal it worked, up to the moment when I needed paging for the result set through
ev.Limit(skip:((request.Page-1) * request.PageSize), rows:request.PageSize)
When using Limit the distinct logically get ignored in building the query, so I get now duplicate Clients.
Is there any other way, or in general is there away to handle subqueries in OrmLite?
Any help is appreciated.
ServiceStack OrmLite (currently at 4.0.x) does not have support for subqueries.
If you look at the 4.0.x docs , there is no discussion of subqueries. JOIN support has been added recently, but for advanced SQL, you need to write it yourself.
Honestly, at a certain point of complexity, SQL is more readable than advanced ORM/LINQ-style queries.

Resources