You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Curl调用Roblox Asset API上传失败,提示FileContent字段必填

解决Roblox Assets API上传400错误(FileContent字段缺失)

核心问题

你的curl命令里,fileContent字段用了远程URL(@"https://raw.githubusercontent.com/..."),但curl的multipart/form-data表单中,@符号仅支持本地文件路径,无法直接拉取远程文件作为表单数据,导致API识别不到有效的fileContent内容,返回必填字段缺失的错误。

解决方案

方案1:先下载文件到本地再上传

  1. 先把模型文件下载到本地:
    curl -O https://raw.githubusercontent.com/rey-debida/cum/refs/heads/main/model.fbx
    
  2. 修改上传命令的fileContent部分,指向本地文件:
    curl --location --request POST 'https://apis.roblox.com/assets/v1/assets' \
    --header 'x-api-key: {api-key}' \
    --form 'request="{ 
      \"assetType\": \"Model\",  
      \"displayName\": \"Name\", 
      \"description\": \"This is a description\", 
      \"creationContext\": { 
        \"creator\": { 
          \"userId\": \"888052552\" 
        } 
      } 
    }"' \
    --form 'fileContent=@./model.fbx;type=model/fbx'
    

方案2:用进程替换直接传递远程文件内容(无需本地保存)

如果不想本地存储文件,可以用bash的进程替换功能,直接把远程文件内容传入表单:

curl --location --request POST 'https://apis.roblox.com/assets/v1/assets' \
--header 'x-api-key: {api-key}' \
--form 'request="{ 
  \"assetType\": \"Model\",  
  \"displayName\": \"Name\", 
  \"description\": \"This is a description\", 
  \"creationContext\": { 
    \"creator\": { 
      \"userId\": \"888052552\" 
    } 
  } 
}"' \
--form 'fileContent=<(curl -s https://raw.githubusercontent.com/rey-debida/cum/refs/heads/main/model.fbx);type=model/fbx'

额外注意事项

  • 你命令中--header 'userId: '是空值,建议直接删除这个无用的请求头,避免潜在的格式问题。
  • 确保{api-key}替换为你的有效Roblox API密钥,并且该密钥拥有资产上传的权限。

内容的提问来源于stack exchange,提问作者Rey Debida

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 08:52:34