C# API请求以反斜杠开头。

huangapple go评论73阅读模式
英文:

C# API Request starts with a Backslash

问题

我对C#和编程相对不太熟悉。我为我的公司制作了一个小程序,可以自动提供新的电话和模式。

直到电话分机/模式更改为以**\+43**开头之前,它都运行正常。在更改之前,只是分机号码(1013),现在是\+435094941013。

这是一个Cisco Unified Call Manager API/ Cisco AXL的问题,但我没有在这个主题上找到任何相关信息 C# API请求以反斜杠开头。

我尝试过:
string line = @"\+43...1013";

string line = "\\+43...1013";

但我总是得到一个空异常/没有找到任何内容...
当我手动更改回旧格式,没有**\+43**时,它可以正常工作。

@编辑:
请求看起来像这样:

string inputline = "\\+435094941013"; // 只使用 1013 也可以工作
string description = "";

var Lines1 = await axlClient.ExecuteAsync(async client =>
{
    var request = new ListLineReq
    {
        returnedTags = new LLine { description = string.Empty },
        searchCriteria = new ListLineReqSearchCriteria { pattern = inputline}
    };
    var response = await client.listLineAsync(request);

    response.listLineResponse1.@return.Select(i => new { Description = i.description }).ToList();

    foreach (var row in response.listLineResponse1.@return.ToList())
    {
        description = row.description;
    }
    return description;
});
英文:

I'm fairly new to c# and programming. I made a little program for my company to automatically provide new telefons and patterns.

It worked fine until the phone extension/pattern got changed to start with \+43. Before the change it was just the extension (1013), now its \+435094941013.

It's a Cisco Unified Call Manager API/ Cisco AXL, but I didn't really find anything regarding this topic C# API请求以反斜杠开头。

I tried:
string line = @"\+43...1013";
and
string line = "\\+43...1013";

but I always get a null exception / nothing was found ...
when I manually change it back to the old format without the \+43 it works.

@edit:
The Request looks like this:

string inputline = "\\+435094941013"; // Works with just 1013
string description = "";           

var Lines1 = await axlClient.ExecuteAsync(async client =>
{
    var request = new ListLineReq
    {
        returnedTags = new LLine { description = string.Empty },
        searchCriteria = new ListLineReqSearchCriteria { pattern = inputline}
    };
    var response = await client.listLineAsync(request);

    response.listLineResponse1.@return.Select(i => new { Description = i.description }).ToList();

    foreach (var row in response.listLineResponse1.@return.ToList())
    {
        description = row.description;
    }
    return description;
});

答案1

得分: 0

CUCM底层数据库使用Informix IDS,其中AXL <listXXX> 请求最终使用SQL LIKE 进行匹配。支持的通配符只是 "_"(代表单个字符)和 "%"(代表任意字符)。您的代码示例似乎使用 "..." 作为 '任意字符' 通配符 - 如果是这样,那可能是问题所在。

仅在HTTP/XML层,<lineLine> 对我来说(在CUCM v14中)似乎可以使用 "%":

...
<searchCriteria>
    <pattern>\\+43%1013</pattern>
</searchCriteria>
...
-------------------------------------------
...
<ns:listLineResponse xmlns:ns="http://www.cisco.com/AXL/API/14.0">
  <return>
    <line uuid="{3D105C47-F16B-1FD3-2527-22A74C79028E}">
      <pattern>\+435094941013</pattern>
...

有可能在您的代码和发送到CUCM的原始XML之间的某个层次中,有一些与保留字符/转义字符等相关的意外操作 - 如果您可以查看实际发送的XML,可能会提供一些线索...

英文:

The underlying database for CUCM is Informix IDS, where AXL &lt;listXXX&gt; requests end up using SQL LIKE for matches. The supported wildcards are simply "_" (for single character) and "%" for any character(s). Your code input example seems to be using "..." as an 'any characters' wildcard - if so, that may be the issue.

Just at the HTTP/XML layer, &lt;lineLine&gt; seems to work for me (CUCM v14) using "%":

...
&lt;searchCriteria&gt;
    &lt;pattern&gt;\\+43%1013&lt;/pattern&gt;
&lt;/searchCriteria&gt;
...
-------------------------------------------
...
&lt;ns:listLineResponse xmlns:ns=&quot;http://www.cisco.com/AXL/API/14.0&quot;&gt;
  &lt;return&gt;
    &lt;line uuid=&quot;{3D105C47-F16B-1FD3-2527-22A74C79028E}&quot;&gt;
      &lt;pattern&gt;\+435094941013&lt;/pattern&gt;
...

It's possible that some layer between your code and the raw XML sent to CUCM is doing something unexpected with reserved characters/escape characters/etc. - if you can view the actual XML being sent, that may provide some clues...

huangapple
  • 本文由 发表于 2023年6月22日 18:01:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530739.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定