Hi
I have issues when run this session:
<Sessionid="2"name="API Login">
<Connectionid="1"name="Credentials">
<Requestverb="POST"url="/api/v1/system/configuration/login">
<!--<Parameters>
<Parameter key="user" pid="135"></Parameter>
<Parameter key="password" pid="136"></Parameter>
</Parameters>-->
<Headers>
<Header key="Content-Type">application/json</Header>
</Headers>
</Request>
<ResponsestatusCode="4">
<Contentpid="5"></Content>
</Response>
</Connection>
</Session>
in wireshark appear this session send post with this body "{"
for login need send this format in POST to endpoint
{
"user":"xxxxxx",
"password":"xxxxxxx"
}
Hi Jose,
On this documentation page you can find an example of how DataMiner encodes the data from the "Parameter" tags when sending a POST (the example right above the "Response" section).
As you have noticed yourself, this is not in the format that you need.
Alternatively you can use the "data" tag, as shown here (the first example).
When using a POST the contents of the data tag is sent as the body, so in your case the contents of that data tag (set with pid='<parameterid>') will need to be the JSON data that you want to send.
The easiest way to put the data in that parameter in the right format will be with a QAction.
Hope this helps.
Kind regards,
Hi Bram,
I use this QAction and work:
using System;
using System.Text;
using Skyline.DataMiner.Scripting;
public static class QAction
{
public static void Run(SLProtocol protocol)
{
try
{
string username = Convert.ToString(protocol.GetParameter(10));
string password = Convert.ToString(protocol.GetParameter(11));
string json = $"{{\"user\":\"{username}\",\"password\":\"{password}\"}}";protocol.SetParameter(12, json);
}
catch (Exception ex)
{
protocol.Log($"QAction Error: {ex.Message}");
}
}
}