チケットシステムのAPIにPowerShell Invoke-RestMethod
を使用し、出力をPowerShellオブジェクトに変換しようとしています。Invoke-RestMethodの出力をオブジェクトに変換する
例として、Invoke-RestMethod
を使用してチケットのプロパティを取得すると、これが表示されます。私が行うことができるようにしたいと思い何
$object = Invoke-RestMethod '[URI here]'
$object.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
$object
EWREST_supported_user0='Yes';
EWREST_updater_team='Support Team';
EWREST_eng_id='CLT';
EWREST_testlabelsub='Test Label';
EWREST_time_created='17:21:03';
EWREST_cr_conversion_related_to='Support Case';
EWREST__1901_full_name='secuser Testuser1';
EWREST_summary='Ticket Title';
EWREST_i_would_like_to_reopen_my_ticket='No';
EWREST_assigned_team_leader='Agiloft Admin';
EWREST_id='183255';
EWREST_severity='Sev 4';
EWREST_problem_description='<div>This is an example of a ticket note that takes up multiple lines when read via API<\/div><div> <\/div><div>Example note info here<\/div><div> <\/div>
<div>Additional example note info here<\/div><div> <\/div><div>Even more note info here<\/div>';
EWREST_demo_data='No';
は$object.EWREST_category
のようなものを行うことによって、オブジェクトとして$object
を操作し、「ネットワーク」を取得することです。ですから、私はどのようにをマニピュレートするかを理解しようとしています。これは、プロパティを持つ伝統的なPowerShellオブジェクトの属性の文字列です。
誰かがそれについてどのように指摘することができますか?
これは私にとってはうまくいくようです。私は1つの問題がありますが、プロパティの1つは複数行のプロパティです。そして、それはConvertFrom-StringDataコマンドを破るようです。つまり、最初の新しい行に "Data Line new line at line:3 char 44は名前=値形式ではありません"と思っています。 – floyd
実際のデータの外観によって異なります。あなたの質問の例を更新してください。 –
複数の行であるConvertFrom-StringDataコマンドで問題が発生するプロパティEWREST_problem_descriptionを含めるように、私のquesitonの例を更新しました。このプロパティの2行目に到達すると、それはname = value形式とは見えません。 – floyd