Appium Driver push file gives a 404

I have a selenium grid setup and one of the nodes in that grid is an appium server. I am testing a web application using protractor, and one of the tests requires me to push an image to the device so it can be used in the test case. Since I cannot directly connect to the appium driver using the selenium driver on the protractor, I am trying to use the api calls to push an image. And i am using the following code

const fileToUpload = '../assets/test.jpg';
const absolutePath = require('path').resolve(__dirname, fileToUpload);
const fileblob = fs.readFileSync(absolutePath, {encoding : 'base64'});
const data = {
  path: '/storage/emulated/0/Downloads/test.jpg',
  data: fileblob
};
console.log(await fetch(appiumHostAddress + sessionid + '/appium/device/push_file', {
  headers: {'content-type': ['image/jpeg']},
  method: 'POST',
  body: JSON.stringify(data)
}).then(async (response) => {
    console.log(response.status);
    if (response.status !== 200)
      console.log(await response);
      console.log(await response.headers);
}));

But I keep getting a 404 error. I tried upgrading java from version 8 to 14, and i still get the same error.

    [AndroidDriver] Screen already unlocked, doing nothing
[AndroidDriver] Starting a chrome-based browser session
[debug] [AndroidDriver] A port was not given, using random free port: 8000
[debug] [AndroidDriver] Automated Chromedriver download is disabled. Use 'chromedriver_autodownload' server feature to enable it
[AndroidDriver] Merging 'goog:chromeOptions' into 'chromeOptions'. This may cause unexpected behavior
[debug] [AndroidDriver] Before starting chromedriver, androidPackage is 'com.android.chrome'
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: C:\Users\x200866\Desktop\Software dev tools\chromedriver.exe
[debug] [Chromedriver] Killing any old chromedrivers, running: wmic process where "commandline like '%chromedriver.exe%--port=8000%'" delete
[debug] [Chromedriver] Successfully cleaned up old chromedrivers
[debug] [Chromedriver] Cleaning any old adb forwarded port socket connections
[debug] [ADB] List forwarding ports
[debug] [ADB] Running 'C:\Users\x200866\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s c02b3be1 forward --list'
[Chromedriver] Spawning chromedriver with: C:\Users\x200866\Desktop\Software dev tools\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[debug] [Chromedriver] Chromedriver version: '85.0.4183.87'
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"value":{"build":{"version":"85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/[email protected]{#1689})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Windows NT","version":"10.0.17134"},"ready":true}}
[Chromedriver] Starting W3C Chromedriver session with capabilities: {
[Chromedriver]   "capabilities": {
[Chromedriver]     "alwaysMatch": {
[Chromedriver]       "goog:chromeOptions": {
[Chromedriver]         "androidPackage": "com.android.chrome",
[Chromedriver]         "args": [
[Chromedriver]           "--use-fake-device-for-media-stream",
[Chromedriver]           "--use-fake-ui-for-media-stream",
[Chromedriver]           "--ignore-certificate-errors"
[Chromedriver]         ],
[Chromedriver]         "androidDeviceSerial": "c02b3be1"
[Chromedriver]       },
[Chromedriver]       "goog:loggingPrefs": {
[Chromedriver]         "browser": "ALL"
[Chromedriver]       }
[Chromedriver]     }
[Chromedriver]   }
[Chromedriver] }
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.android.chrome","args":["--use-fake-device-for-media-stream","--use-fake-ui-for-media-stream","--ignore-certificate-errors"],"androidDeviceSerial":"c02b3be1"},"goog:loggingPrefs":{"browser":"ALL"}}}}
[debug] [Chromedriver] Webview version: 'Chrome/86.0.4240.110'
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[debug] [GENERIC] Calling AppiumDriver.getStatus() with args: []
[debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.17.1"}}
[HTTP] <-- GET /wd/hub/status 200 16 ms - 68
[HTTP]
[debug] [WD Proxy] Got response with status 200: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"86.0.4240.110","chrome":{"chromedriverVersion":"85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/[email protected]{#1689})"},"goog:chromeOptions":{"debuggerAddress":"localhost:64028"},"pageLoadStrategy":"normal","platformName":"android","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":false},"sessionId":"64a69035f3fda9d4487ae1a29d1a99f7"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[debug] [Chromedriver] Changed state to 'online'
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8201/wd/hub/session/904a3b30-d07d-472e-b250-f23c9138b99e/appium/device/pixel_ratio] with body: {}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"904a3b30-d07d-472e-b250-f23c9138b99e","value":2.375}
[debug] [WD Proxy] Matched '/appium/device/system_bars' to command name 'getSystemBars'
[debug] [WD Proxy] Proxying [GET /appium/device/system_bars] to [GET http://127.0.0.1:8201/wd/hub/session/904a3b30-d07d-472e-b250-f23c9138b99e/appium/device/system_bars] with body: {}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"904a3b30-d07d-472e-b250-f23c9138b99e","value":{"statusBar":80}}
[debug] [WD Proxy] Matched '/window/current/size' to command name 'getWindowSize'
[debug] [WD Proxy] Proxying [GET /window/current/size] to [GET http://127.0.0.1:8201/wd/hub/session/904a3b30-d07d-472e-b250-f23c9138b99e/window/current/size] with body: {}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"904a3b30-d07d-472e-b250-f23c9138b99e","value":{"height":2260,"width":1080}}
[Appium] New AndroidUiautomator2Driver session created successfully, session fc1a4b41-5676-458b-b504-061969f6c83a added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1603894766884 (10:19:26 GMT-0400 (Eastern Daylight Time))
[debug] [W3C (fc1a4b41)] Cached the protocol value 'W3C' for the new session fc1a4b41-5676-458b-b504-061969f6c83a
[debug] [W3C (fc1a4b41)] Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"acceptInsecureCerts":true,"browserName":"chrome","goog:chromeOptions":{"args":["--use-fake-device-for-media-stream","--use-fake-ui-for-media-stream","--ignore-certificate-errors"]},"platformName":"android","server:CONFIG_UUID":"53bf500f-43b1-4600-bc40-ff8a20fb36eb","automationName":"UiAutomator2","count":1,"udid":"c02b3be1","deviceName":"Samsung Note device","seleniumAddress":"http://100.67.13.190:8082/wd/hub"},"acceptInsecureCerts":true,"browserName":"chrome","goog:chromeOptions":{"args":["--use-fake-device-for-media-stream","--use-fake-ui-for-media-stream","--ignore-certificate-errors"]},"platformName":"android","server:CONFIG_UUID":"53bf500f-43b1-4600-bc40-ff8a20fb36eb","automationName":"UiAutomator2","count":1,"udid":"c02b3be1","deviceName":"c02b3be1","seleniumAddress":"http://100.67...
[HTTP] <-- POST /wd/hub/session 200 15592 ms - 1475
[HTTP]
[HTTP] --> POST /wd/hub/session/fc1a4b41-5676-458b-b504-061969f6c83a/timeouts
[HTTP] {"script":90000}
[W3C (fc1a4b41)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/fc1a4b41-5676-458b-b504-061969f6c83a/timeouts' to command name 'timeouts'
[debug] [Protocol Converter] Will send the following request bodies to /timeouts: [{"script":90000}]
[debug] [WD Proxy] Proxying [POST /wd/hub/session/fc1a4b41-5676-458b-b504-061969f6c83a/timeouts] to [POST http://127.0.0.1:8000/wd/hub/session/64a69035f3fda9d4487ae1a29d1a99f7/timeouts] with body: {"script":90000}
[debug] [WD Proxy] Got response with status 200: {"value":null}
[HTTP] <-- POST /wd/hub/session/fc1a4b41-5676-458b-b504-061969f6c83a/timeouts 200 51 ms - 14
[HTTP]
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[debug] [GENERIC] Calling AppiumDriver.getStatus() with args: []
[debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.17.1"}}
[HTTP] <-- GET /wd/hub/status 200 3 ms - 68
[HTTP]
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[debug] [GENERIC] Calling AppiumDriver.getStatus() with args: []
[debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.17.1"}}
[HTTP] <-- GET /wd/hub/status 200 10 ms - 68
[HTTP]
[HTTP] --> POST /wd/hubfc1a4b41-5676-458b-b504-061969f6c83a/appium/device/push_file
[HTTP] {}
[debug] [HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- POST /wd/hubfc1a4b41-5676-458b-b504-061969f6c83a/appium/device/push_file 404 6 ms - 109
[HTTP]
[HTTP] --> GET /wd/hub/status

Can I get some help? Thanks

The push file command only works in native context

Thanks for that information!