Skip to content

Uploading runs via API, getting 'Method Not Allowed' (status 405) #812

Answered by slashinfty
slashinfty asked this question in Q&A
Discussion options

You must be logged in to vote

It would appear that using the formdata-node package along with fs.readFileSync() instead of the JS object worked. Thanks!

Working code, in case it helps others in the future:

// Import modules
import * as fs from 'fs';
import fetch from 'node-fetch';
import { FormData } from "formdata-node"

// Import files
import { config } from '../index.js';
import { splits } from './Splits.js';

export const upload = async () => {
    const probe = await fetch(`https://splits.io/api/v4/runs`, {
        method: "POST"
    });
    const response = await probe.json();

    if (response.status !== 201) {
        return 'Upload failed.';
    }

    const body = new FormData();
    for (const key in response.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by glacials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants