0
Google 애플리케이션 용 REST API를 구축하고 있습니다. 지금까지 기본이 작동합니다. 서비스에 연결할 수 있으며 명령을 호출합니다. 그러나, 내 방법 중 하나에서, (문자열) luceneQuery라는 매개 변수가 있고 메서드 매개 변수를 넣거나 URL 매개 변수에 입력 한 것과 관계없이 항상 null 또는 비어 있습니다.C# REST API, URL 매개 변수가 null입니다.
나는 솔직히이 것을 이해할 수 없다. 그리고 나는 몇 시간 동안 그것을 가지고 있었다. 심지어 구글은 나를 미워하고있다.
public const string SearchRoute = "/search/{domain}/{query}/{outputType}";
은 다음 호출 방법은대로 :
[OperationContract]
[WebGet(UriTemplate = Routing.SearchRoute, BodyStyle = WebMessageBodyStyle.Bare)]
string SearchIndex(string domain, string luceneQuery, OutputType outputType);
: 방법은 인터페이스에서 구현되는
public string SearchIndex(string domain, string luceneQuery, OutputType outputType) {
if (string.IsNullOrEmpty(domain))
throw new ArgumentNullException(nameof(domain));
else if (string.IsNullOrEmpty(luceneQuery))
throw new ArgumentNullException(nameof(luceneQuery));
var byteArray = Convert.FromBase64String(luceneQuery);
luceneQuery = Encoding.UTF8.GetString(byteArray);
return ExecuteCommand("search", outputType == OutputType.Json ? "-json" : "", "--default", domain, luceneQuery);
}
여기
내가 사용하고 경로입니다그리고 내 웹 브라우저의 응용 프로그램에서 얻은 결과는 다음과 같습니다.
<Code>
<Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:InternalServiceFault</Value>
</Code>
<Reason>
<Text xml:lang="en-US">Value cannot be null. Parameter name: luceneQuery</Text>
</Reason>
<Detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>Value cannot be null. Parameter name: luceneQuery</Message>
<StackTrace>
at De.Nwt.MailArchive.RestService.RestService.SearchIndex (System.String domain, System.String luceneQuery, De.Nwt.MailArchive.RestService.OutputType outputType) [0x00027] in /Users/simoncahill/Projects/MailArchive/RestService/Src/Classes/RestService.cs:104 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /private/tmp/source-mono-4.6.0/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
</StackTrace>
<Type>System.ArgumentNullException</Type>
</ExceptionDetail>
</Detail>
도움을 주시면 미리 감사드립니다.
힌트를 얻으려는 시도를하겠습니다. – SimonC
슬프게도 도움이되지 않았습니다. 변경된 매개 변수 이름과 동일한 오류가 발생합니다. – SimonC
사실, 나는 그걸 취했다. 나는 인터페이스에서 매개 변수의 이름을 변경하지 않았다. 그렇게 한 후에, 그것은 매력처럼 작동합니다. – SimonC