
Announcements
I am receiving a 404 "Resource Not Found" error while sending a PATCH request within the script.csx code in a very simple custom connector. Of course a PATCH request for a swagger operation works in general if that operation is not forwarded through the script (ScriptBase). But if I change the operation to be a part of the "scriptOperations" (in apiProperties.json) and then just simply forward the request along using
return await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);then I see a 404 and have confirmed the request is not making it to destination PATCH endpoint. It's almost as though the Http Client running within the script runtime doesn't support PATCH and just throws a 404.
Is anyone else experiencing this problem, or could try to setup a simple custom connector to reproduce this before I log a bug?
Repro steps:
- Create a custom connector with a patch operation (see example below)
- Ensure the operation succeeds when not forwarding through the csx script.
- Now add the operation as a part of "scriptOperations" in apiProperties.json
- Provide a script.csx file that overrides Task<HttpResponseMessage> ExecuteAsync from ScirptBase and forward the request along using SendAsync (see below)
Swagger operation (apiDefinition.swagger.json):
"paths": {
"/myendpoint": {
"patch": {
"operationId": "MyOperation",
"summary": "Operation Patch summary",
"description": "Operation description.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/InBody"
},
"description": "An object.",
"required": true
}
],
"responses": {
"200": {
"description": "Indicates a successful response.",
"schema": {}
}
}
}
}
},
"definitions": {
"InBody": {
"type": "object"
}
}
Script (script.csx):
public class Script : ScriptBase
{
public override async Task<HttpResponseMessage> ExecuteAsync()
{
try
{
return await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
}
catch (ConnectorException ex)
{
var response = new HttpResponseMessage(ex.StatusCode);
response.Content = CreateJsonErrorResponse(ex.Message);
return response;
}
}
}
I am experiencing this same issue with my custom connector. It specifically is for PATCH requests and the "NotFound" error is not coming from the actual endpoint that I am targeting, instead it seems it is being returned before the actual request is sent. Did you find a workaround for this?
--UPDATE--
I restructured my custom connector so that the code is not used for PATCH requests, they now run without errors. The problem seems to have been specifically related to enabling custom code on PATCH requests.