# Upload config file using API

**URL:** <https://forum.genieacs.com/t/upload-config-file-using-api/417>\
**Category:** Uncategorized\
**Created:** [November 3, 2019, 11:52pm UTC](https://forum.genieacs.com/t/upload-config-file-using-api/417 "2019-11-03T23:52:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@Nolan](https://forum.genieacs.com/u/Nolan)\
**Post date:** [November 3, 2019, 11:52pm UTC](https://forum.genieacs.com/t/upload-config-file-using-api/417/1 "2019-11-03T23:52:07Z")

</div>

Hi community,

I have an issue with uploading the file using API to GenieACS.

I got the following error code when I running the code:

PS C:\Users\nzhang\testingCode\> node .\savetxt.js  
problem with request: getaddrinfo ENOTFOUND [http://10.228.228.3](http://10.228.228.3)  
PS C:\Users\nzhang\testingCode\>

Suspect it is a network issue:

PS C:\Users\nzhang\testingCode\> Test-NetConnection 10.228.228.3 -p 80  
WARNING: TCP connect to (10.228.228.3 : 80) failed

ComputerName : 10.228.228.3  
RemoteAddress : 10.228.228.3  
RemotePort : 80  
InterfaceAlias : VirtualBox Host-Only Network #3  
SourceAddress : 10.228.228.254  
PingSucceeded : True  
PingReplyDetails (RTT) : 0 ms  
TcpTestSucceeded : False

My code is in below:

const http = require(‘http’);  
const options = {  
hostname: ‘[http://10.228.228.3](http://10.228.228.3)’,  
port: 3000,  
path: ‘/files’,  
method: ‘PUT’,  
headers: {  
‘fileType’: ‘3 Vendor Configuration File’,  
‘oui’: ‘70FC8C’,  
‘productClass’: ‘MB425SAV2ad0UFPE4BuNW’,  
‘version’: ‘2.0’,  
}  
};

const req = http.request(options, (res) =\> {  
console.log(`STATUS: ${res.statusCode}`);  
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);  
res.setEncoding(‘utf8’);  
res.on(‘data’, (chunk) =\> {  
console.log(`BODY: ${chunk}`);  
});  
res.on(‘end’, () =\> {  
console.log(‘No more data in response.’);  
});  
});

req.on(‘error’, (e) =\> {  
console.error(`problem with request: ${e.message}`);  
});

// Write data to request body  
req.write(template);  
req.end();

---

<div class="post-metadata">

**Author:** ![Nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@Nolan](https://forum.genieacs.com/u/Nolan)\
**Post date:** [November 4, 2019, 4:46am UTC](https://forum.genieacs.com/t/upload-config-file-using-api/417/2 "2019-11-04T04:46:17Z")

</div>

Hi Community,

I got the following message when I executed the code. Could you please advise the reason I got “405 Method Not Allow”?

PS C:\Users\nzhang\testingCode\> node .\savetxt.js  
STATUS: 405  
HEADERS: {“allow”:“GET”,“date”:“Mon, 04 Nov 2019 04:43:07 GMT”,“connection”:“close”,“transfer-encoding”:“chunked”}  
BODY: 405 Method Not Allowed  
No more data in response.  
PS C:\Users\nzhang\testingCode\>

My code is in below:

const options = {  
host: ‘10.228.228.3’,  
port: 7567,  
path: ‘/files/newfile.cfg’,  
method: ‘PUT’, // POST  
headers: {  
‘fileType’: ‘3 Vendor Configuration File’,  
‘oui’: ‘70FC8C’,  
‘productClass’: ‘MB425SAV2ad0UFPE4BuNW’,  
‘version’: ‘2.0’,  
}  
};

const req = http.request(options, function(res) {  
console.log(`STATUS: ${res.statusCode}`);  
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);  
// res.setEncoding(‘utf8’);  
res.on(‘data’, function (chunk) {  
console.log(`BODY: ${chunk}`);  
});  
res.on(‘end’, function() {  
console.log(‘No more data in response.’);  
});  
});

req.on(‘error’, function(e) {  
console.error(`problem with request: ${e.message}`);  
});

req.write(template);  
req.end();

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [November 4, 2019, 6:43am UTC](https://forum.genieacs.com/t/upload-config-file-using-api/417/3 "2019-11-04T06:43:26Z")

</div>

Hi Nolan,  
if you’re using the default config, then you should make all API calls to the NBI (port 7557) and not to the UI (port 3000) or the FS (port 7567).

---

<div class="post-metadata">

**Author:** ![Nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@Nolan](https://forum.genieacs.com/u/Nolan)\
**Post date:** [November 5, 2019, 5:03am UTC](https://forum.genieacs.com/t/upload-config-file-using-api/417/4 "2019-11-05T05:03:15Z")

</div>

Sorted. Thanks. 😁
