Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
405 POST method not allowed (clarifai)

am trying to use the clarify face detection api on my react app but i keep getting an error POST: 405 method not allowed i have tried going through some solutions here on stack overflow but it seems am using the updated version of clarifai api request method and is not in line with the solutions i have come across can someone please help me out with this am new to this

below is the app.js code

import NavBar from "../components/navbar/NavBar";
import ImageLinkFrom from "../components/imagelinkform/ImageLinkFrom";
import ImageRecognition from "../components/imagerecognition/Imagerecognition";
import Logo from "../components/logo/Logo";
import "./App.css";
import Rank from "../components/rank/Rank";
import { useState } from "react";
import Clarifai from "clarifai";

function App() {
  const [input, setInput] = useState("");
  const [imageurl, setImageurl] = useState("");

  const onInputChange = (e) => {
    setInput(e.target.value);
  };

  const onButtonSubmit = () => {
    setImageurl(input);
    const USER_ID = "myUserId";
    // Your PAT (Personal Access Token) can be found in the portal under Authentification
    const PAT = "myPAT";
    const APP_ID = "myAppId";
    const MODEL_ID = "color-recognition";
    // const MODEL_VERSION_ID = "45fb9a671625463fa646c3523a3087d5";
    // Change this to whatever image URL you want to process
    const IMAGE_URL = "https://samples.clarifai.com/metro-north.jpg";

    const raw = JSON.stringify({
      user_app_id: {
        user_id: USER_ID,
        app_id: APP_ID,
      },
      inputs: [
        {
          data: {
            image: {
              base64: IMAGE_URL,
            },
          },
        },
      ],
    });

    const requestOptions = {
      method: "POST",
      headers: {
        Accept: "application/json",
        Authorization: "Key " + PAT,
      },
      body: raw,
    };
    debugger;

    fetch(
      "https://api.clarifai.com/v2/models/" +
        MODEL_ID +
        "/versions/" +
        "/outputs",
      requestOptions
    )
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.log("error", error));
  };

  return (
    <div className="App">
      <NavBar />
      <Logo />
      <Rank />
      <ImageLinkFrom
        onInputChange={onInputChange}
        onButtonSubmit={onButtonSubmit}
      />
      <ImageRecognition imageurl={imageurl} />
    </div>
  );
}

export default App;

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

User, app and version id need to go to the url.

Remove this part from the req body:

user_app_id: {
    user_id: USER_ID,
    app_id: APP_ID,
  },

Change the path:

fetch(
      "https://api.clarifai.com/v2/users/"+
        USER_ID +
        "/apps/" +
        APP_ID +
        "/models/" +
        MODEL_ID +
        "/versions/" +
        MODEL_VERSION_ID +
        "/outputs",
      requestOptions
    )

Or without version (using the latest by default)

fetch(
      "https://api.clarifai.com/v2/users/"+
        USER_ID +
        "/apps/" +
        APP_ID +
        "/models/" +
        MODEL_ID +
        "/outputs",
      requestOptions
    )
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!