How to fix Http request failure when trying to query the Microsoft Dataverse Web API from Power Automate? - httprequest

I'm trying to retrieve all the users and their roles across some environments in my Office 365 tenant using a Power Automate flow, but when I'm trying to query the Dataverse Web API either with OData or fetchXml, I always get the same error:
At this point I don't have any clue on how to fix it, if anyone could point me in the right direction I would really appreciate it. I also tried this in postman and it works without problem.
Thanks for your help.
I'm adding some extra information below.
URI
https://someorg.crm2.dynamics.com/api/data/v9.2/systemusers
Headers
{
"Accept": "application/json",
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Prefer": "odata.include-annotations=\"*\"",
"If-None-Match": "null",
"Content-Type": "application/json; charset=utf-8"
}
Query
<fetch top="1000">
<entity name="systemuser">
<attribute name="fullname" />
<attribute name="domainname" />
<link-entity name="systemuserroles" from="systemuserid" to="systemuserid" intersect="true">
<link-entity name="role" from="roleid" to="roleid" intersect="true">
<attribute name="name" />
<attribute name="roleid" />
</link-entity>
</link-entity>
</entity>
</fetch>

Related

Shibboleth Attributes not Mapping

We are having an issue with Shibboleth and Apache Server. I am integrating with an SSO portal for a Tomcat application. I have the integration with the SSO portal figured out, but we are having an issue with the mapping of the attributes. We are obtaining a NameID which is the email address. I don’t know what I am missing. I can see the email in the Shibd.log, but I cannot see any attributes in the Shibboleth.sso/Session
Here is my configuration for the attribute-map:
<Attributes xmlns="urn:mace:shibboleth:2.0:attribute-map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Attribute name="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" id="persistent-id">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$NameQualifier!$SPNameQualifier!$Name" defaultQualifiers="true"/>
</Attribute>
<Attribute name="emailAddress" nameFormat="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" id="emailAddress">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true" />
</Attribute>
<Attribute name="mail" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" id="mail">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true" />
</Attribute>
</Attributes>
Here is what I have in the Attribute-Policy:
<afp:AttributeFilterPolicyGroup
xmlns="urn:mace:shibboleth:2.0:afp:mf:basic"
xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic"
xmlns:afp="urn:mace:shibboleth:2.0:afp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<afp:AttributeFilterPolicy>
<!-- This policy is in effect in all cases. -->
<afp:PolicyRequirementRule xsi:type="ANY"/>
<!-- Catch-all that passes everything else through unmolested. -->
<afp:AttributeRule attributeID="*" permitAny="true"/>
</afp:AttributeFilterPolicy>
</afp:AttributeFilterPolicyGroup>
The Shibd.log has the following verbiage:
019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute urn:oasis:names:tc:SAML:2.0:nameid-format:persistent
2019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute emailAddress, Format/Namespace:urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
2019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute mail, Format/Namespace:urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified
However, as previously mentioned we cannot see any attributes in Shibboleth.sso/Session
Am I missing anything?
This was fixed by adding the attributes:
<Attribute name="urn:mace:dir:attribute-def:mail" id="SHIB_MAIL"/>
<Attribute name="urn:oid:0.9.2342.19200300.100.1.3" id="SHIB_MAIL"/>
This was the only attribute that showed up in the attribute portion of the SP Session.

Execution of Fetch XML using Web API Dynamics 365

I am using this approach for paging using Fetch XML within Web API.
Web API works perfect when we use simple fetch and it returns pagging cookie along with results if there are more records but when we use complex(where we have link entities) Fetch XML it returns paging cookie but empty e.g.:
<b><cookie pagenumber="2" pagingcookie="" istracking="False" /></b>
Here you can see we have nothing in pagingcookie.
Fetch XML used for query:
<fetch mapping="logical" version="1.0" output-format="xml-platform" count="10" page="1" >
<entity name="invoicedetail" >
<attribute name="invoicedetailid" />
<attribute name="uomid" />
<attribute name="quantity" />
<attribute name="manualdiscountamount" />
<attribute name="priceperunit" />
<attribute name="extendedamount" />
<filter>
<condition entityname="invoice" attribute="customerid" operator="eq" value="{5A8F8B46-2443-E511-80E3-3863BB351E10}" />
</filter>
<link-entity name="invoice" from="invoiceid" to="invoiceid" >
<attribute name="invoiceid" />
<attribute name="invoicenumber" />
<attribute name="description" />
<attribute name="totalamount" />
<order attribute="ss_postingdate" descending="true" />
</link-entity>
</entity>
</fetch>
If we remove linked entity it starts giving the exact paging cookie in the response that can be get using #Microsoft.Dynamics.CRM.fetchxmlpagingcookie.
Is there any way to get the exact paging cookie in complex scenarios?
I've seen this happen before in the standard organization service. I would suggest just paging without the paging cookie - this resolved the issue for me in the organization service.
E.g. <fetch mapping="logical" page="1" count="50">

Dynamics CRM 2015 - Retrieve all Contact that are in any way connected to Opportunity

I need to present all contact that have connection to opportunity in dialog. So when some opportunity has Sales Team, Stakeholders, Owners, etc. Something like Active Connection Associate View. I need a FetchXml or other ways to find all the Contact that are in any way connected to current opened Opportunity.
Your fetchXML query will look quite like this :
<fetch mapping='logical' version='1.0'>
<entity name='myentity'>
<filter>
<condition attribute='myentityid' operator='eq' value='myvalue' />
</filter>
<link-entity name='secondentity' from='stsr_materialid' to='stsr_material_casinglookup' alias='c' link-type='outer'>
<attribute name='stsr_name' />
<attribute name='stsr_code_aisi' />
<attribute name='stsr_code_astm' />
<attribute name='stsr_code_din' />
<attribute name='stsr_code_e' />
<attribute name='stsr_code_en' />
</link-entity>
If you need more help, please provide more context.

FetchXML nvarchar returns nothing - Custom Report for CRM

I am trying to get data from Dynamics CRM 2013 for a custom report using FetchXML.
I "converted" the following SQL Query to FetchXML using this page: http://www.sql2fetchxml.com/
SQL:
SELECT
accountidname,
billto_line1,
billto_postalcode,
billto_city,
invoicenumber,
name,
description
FROM FilteredInvoice
WHERE invoiceid = #invoiceid
FetchXML:
<fetch mapping="logical">
<entity name="invoice">
<attribute name="accountidname" />
<attribute name="billto_line1" />
<attribute name="billto_postalcode" />
<attribute name="billto_city" />
<attribute name="invoicenumber" />
<attribute name="name" />
<attribute name="description" />
<filter>
<condition attribute="invoiceid" operator="eq" value="#invoiceid" />
</filter>
</entity>
</fetch>
Both, "accountidname" and (e.g.) "billto_line1" are NVARCHAR(4000) and both contain data, but if I try to execute the query (e.g. in the "Query Designer" in Visual Studio) only the data of "billto_line1" is shown, not the data of "accountidname".
Since both fields "accountidname" and "billto_line1" are of the same type (nvarchar(4000)) and contain information in the database (I checked it with the "Microsoft SQL Server Management Studio") I am wondering why I can only receive the information from one of those two.
This has happend with many different fields of the type NVARCHAR - some are displayed correctly, while some are not - and I have no idea why.
I would be very pleased if somebody could give me a hint :)
Thank you
accountidname is on the Views, not the actual tables, in SQL. It is not a field on the invoice entity and therefore will not return any information in a FetchXml request.
You should be able to retrieve the Account's name by using accountid - I don't remember in SSRS how the Name property of an EntityReference is surfaced but it should be available.
The FetchXml converter is good at converting SQL SELECT's to FetchXml format and converting joins. It will not validate that the SQL fields are available in FetchXml - that could only be done by accessing the metadata of the CRM Org.

SSRS can't use "Required Attendees" in dataset?

I am creating report in SSRS for CRM. I have a table with Dataset for Appointment info and I noticed that it does not allow me to report on required attendees??? Is this true? If so is there a workaround around this? I basically want my report to show appointments details and of course who participated.
Any advice is much appreciated!
Below is the fetchXML I gathered from using Advanced Find in CRM 2013.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="appointment">
<attribute name="subject"/>
<attribute name="statecode"/>
<attribute name="scheduledstart"/>
<attribute name="activityid"/>
<attribute name="instancetypecode"/>
**<attribute name="requiredattendees"/>**
<order attribute="subject" descending="false"/>
<link-entity name="account" from="accountid" to="regardingobjectid" alias="ae">
<filter type="and">
<condition attribute="accountid" operator="eq" value="#name"/>
</filter>
</link-entity>
</entity>
</fetch>
To get this information you will have to create another one datasource and retrieve information from ActivityParty entity. All items like requiredattendees, optionalattendees in appointment, from, to, cc, bcc in email, e.t.c. are stored inside ActivityParty entity.