Enviando NFe json PHP Sandbox

Amigos, enviei esse json, como $payload

{
  "infNFe": {
    "ide": {
      "cUF": 42,
      "cNF": "94328487",
      "natOp": "REMESSA",
      "mod": 55,
      "serie": 2,
      "nNF": 1,
      "dhEmi": "2024-06-25T15:01:02Z",
      "dhSaiEnt": "2024-06-25T15:01:02Z",
      "tpNF": 1,
      "idDest": 1,
      "cMunFG": "4202404",
      "tpImp": 1,
      "tpEmis": 1,
      "cDV": 7,
      "tpAmb": 1,
      "finNFe": 1,
      "indFinal": 1,
      "indPres": 1,
      "procEmi": 0
    },
    "emit": {
      "CNPJ": "33911101000173",
      "xNome": "Moda Cores Ltda",
      "xFant": "Modacores",
      "enderEmit": {
        "xLgr": "Rua Almirante Barroso",
        "nro": "387",
        "xCpl": "",
        "xBairro": "Bras",
        "cMun": "50308",
        "xMun": "Sao Paulo",
        "UF": "SP",
        "CEP": "08773300",
        "cPais": "01058",
        "xPais": "BRASIL",
        "fone": "4732889978"
      },
      "IE": "126243189115",
      "CRT": 3
    },
    "dest": {
      "CNPJ": "03061133000166",
      "xNome": "STAACK TINTURARIA LTDA",
      "enderDest": {
        "xLgr": "RUA ITAJAI",
        "nro": "100",
        "xCpl": "",
        "xBairro": "LIMOEIRO",
        "cMun": "02909",
        "xMun": "Brusque",
        "UF": "SC",
        "CEP": " 0000000",
        "cPais": "01058",
        "xPais": "BRASIL",
        "fone": "4733554000"
      },
      "indIEDest": 1,
      "IE": "253728240",
      "email": ""
    },
    "retirada": {
      "CNPJ": "33911101000173",
      "xNome": "Moda Cores Ltda",
      "xLgr": "Rua Almirante Barroso",
      "nro": "387",
      "xCpl": "",
      "xBairro": "Bras",
      "cMun": "50308",
      "xMun": "Sao Paulo",
      "UF": "SP",
      "CEP": "08773300",
      "cPais": "01058",
      "xPais": "BRASIL",
      "fone": "4732889978",
      "email": "pcp@modacores.com.br",
      "IE": "126243189115"
    },
    "det": [
      {
        "nItem": 1,
        "prod": {
          "cProd": "15502",
          "cEAN": "SEM GTIN",
          "xProd": "MOLETON PARIS SOFT MOL-285",
          "NCM": "3041912",
          "CFOP": "6901",
          "uCom": "KG",
          "qCom": 1348.400,
          "vUnCom": 19.00,
          "vProd": 25619.60000,
          "cEANTrib": "SEM GTIN",
          "uTrib": "25619.60000",
          "qTrib": 1348.400,
          "vUnTrib": 19.00,
          "indTot": 1
        },
        "imposto": {
          "vTotTrib": 0,
          "ICMS": {
            "ICMS40": {
              "orig": 2,
              "CST": "50",
              "vICMSDeson": 0,
              "motDesICMS": 0,
              "indDeduzDeson": 0
            }
          },
          "PIS": {
            "PISNT": {
              "CST": "08"
            }
          },
          "COFINS": {
            "COFINSNT": {
              "CST": "08"
            }
          }
        }
      }
    ],
    "total": {
      "ICMSTot": {
        "vBC": 0,
        "vICMS": 0,
        "vICMSDeson": 0,
        "vFCP": 0,
        "vBCST": 0,
        "vST": 0,
        "vFCPST": 0,
        "vFCPSTRet": 0,
        "vProd": 25619.60000,
        "vFrete": 0,
        "vSeg": 0,
        "vDesc": 0,
        "vII": 0,
        "vIPI": 0,
        "vIPIDevol": 0,
        "vPIS": 0,
        "vCOFINS": 0,
        "vOutro": 0,
        "vNF": 0
      }
    },	  
    "transp": {
      "modFrete": 0,
      "transporta": {
        "CNPJ": "29970567000172",
        "xNome": "TRANSIT CARGO LTDA",
        "xEnder": "RUA BUSINESS PARK",
        "xMun": "BLUMENAU",
        "UF": "SC"
      },
      "vol": [
        {
          "qVol": 8,
          "esp": "VOLUME",
          "nVol": "0",
          "pesoL": 230.400,
          "pesoB": 270.800
        }
      ]
    },
	"pag": {
	"detPag": [
	  {
		"indPag": 0,
		"tPag": "90",
		"vPag": 0
	  }
	]
	},
    "infAdic": {
      "infAdFisco": ""
    },
    "infRespTec": {
      "CNPJ": "21214930000118",
      "xContato": "OPENSOFT INFORMATICA EIRELI - ME",
      "email": "james.isecke@hotmail.com",
      "fone": "62981261148"
    }
  },
  "ambiente": "homologacao",
  "referencia": "667b05dedc671"
}

usando os códigos:

$nfe='';
$endpoint = "'https://api.sandbox.nuvemfiscal.com.br/nfe";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_POST, 1);    
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded',"Authorization: Bearer $token" ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_response = curl_exec($ch);
$error = curl_error($ch);
$errno = curl_errno($ch);
curl_close ($ch);
	
echo 'server_response = '.$server_response."<br/>";
echo 'error = '.$error."<br/>";
echo 'errno = '.$errno."<br/>";

Só que deu esse erro:

server_response = { "error": { "code": "UnsupportedMediaType", "message": "Unsupported media type: application/x-www-form-urlencoded" } }
error =
errno = 0

o que pode ser?

ok já deu certo era esse trecho do código já troquei e resolveu:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',"Authorization: Bearer $token" ));

Este tópico foi fechado automaticamente 24 horas depois da última resposta. Novas respostas não são mais permitidas.