web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / 404 Resource Not Found...
Power Apps
Unanswered

404 Resource Not Found sending PATCH request via IScriptContext.SendAsync

(1) ShareShare
ReportReport
Posted on by 4

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;
 } 
 }
}

 

Categories:
I have the same question (0)
  • dagrenzer Profile Picture
    9 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard