Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda