在 Pentaho Spoon 中,我尝试构建将从 Azure AD 读取数据的转换,然后将此数据推送到另一个应用程序。
现在我面临的问题是分页,我无法从第一个 REST 调用中检索下一个 URL 变量。
在第一个 REST 调用中,我可以看到如下所示的正文:
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","@odata.nextLink":"https://graph.microsoft.com/v1.0/users/?$skiptoken=RFNwdAIAAQAAACg6YWJkdWxsYWgucmFzaGVlZGlAYWR2YW5jZWRwZXRyb2NoZW0uY29tKVVzZXJfNDcwMGFmNGEtMjliMi00M2ZjLThlOWYtYzk3MGNkMTM5NTIzuQAAAAAAAAAAAAA","value":[{"id":"34543".......................}]}
实际问题从这里开始,在 Pentaho 转换中,我使用 Json 输入来提取路径下方的下一个 URL(尝试使用以下所有路径。)
${@odata.nextLink} OR $.{@odata.nextLink} OR $..{@odata.nextLink} OR [email protected]
但不幸的是,没有任何效果。
我在谷歌搜索如何从另一个 API 获取 @odata.count 时偶然发现了这篇文章。因为我没有找到可搜索的答案,所以我不得不在一些我已经解决了它的旧工作中查找它。
所以我将答案发布在这里,供我将来或其他人寻找。 你可以用括号表示法得到它 - ['@odata.nextLink']
以下可粘贴测试:
<?xml version="1.0" encoding="UTF-8"?>
<transformation-steps>
<steps>
<step>
<name>Generate rows</name>
<type>RowGenerator</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>json</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<nullif>{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","@odata.nextLink":"https://graph.microsoft.com/v1.0/users/?$skiptoken=RFNwdAIAAQAAACg6YWJkdWxsYWgucmFzaGVlZGlAYWR2YW5jZWRwZXRyb2NoZW0uY29tKVVzZXJfNDcwMGFmNGEtMjliMi00M2ZjLThlOWYtYzk3MGNkMTM5NTIzuQAAAAAAAAAAAAA","value":[{"id":"34543"}]}</nullif>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<limit>1</limit>
<never_ending>N</never_ending>
<interval_in_ms>5000</interval_in_ms>
<row_time_field>now</row_time_field>
<last_time_field>FiveSecondsAgo</last_time_field>
<attributes></attributes>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>294</xloc>
<yloc>175</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>JSON input</name>
<type>JsonInput</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<include>N</include>
<include_field/>
<rownum>N</rownum>
<addresultfile>N</addresultfile>
<readurl>N</readurl>
<removeSourceField>N</removeSourceField>
<IsIgnoreEmptyFile>N</IsIgnoreEmptyFile>
<doNotFailIfNoFile>Y</doNotFailIfNoFile>
<ignoreMissingPath>Y</ignoreMissingPath>
<defaultPathLeafToNull>Y</defaultPathLeafToNull>
<includeNulls>N</includeNulls>
<rownum_field/>
<file>
<name/>
<filemask/>
<exclude_filemask/>
<file_required>N</file_required>
<include_subfolders>N</include_subfolders>
</file>
<fields>
<field>
<name>odata_nextLink</name>
<path>['@odata.nextLink']</path>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<trim_type>none</trim_type>
<repeat>N</repeat>
</field>
</fields>
<limit>0</limit>
<IsInFields>Y</IsInFields>
<IsAFile>N</IsAFile>
<valueField>json</valueField>
<shortFileFieldName/>
<pathFieldName/>
<hiddenFieldName/>
<lastModificationTimeFieldName/>
<uriNameFieldName/>
<rootUriNameFieldName/>
<extensionFieldName/>
<sizeFieldName/>
<attributes></attributes>
<cluster_schema/>
<remotesteps>
<input>
</input>
<output>
</output>
</remotesteps>
<GUI>
<xloc>406</xloc>
<yloc>175</yloc>
<draw>Y</draw>
</GUI>
</step>
</steps>
<order>
<hop>
<from>Generate rows</from>
<to>JSON input</to>
<enabled>Y</enabled>
</hop>
</order>
<notepads>
</notepads>
<step_error_handling>
</step_error_handling>
</transformation-steps>