知识库文件转换

更新时间:

excel转docx文件上传接口

HTTP接口

shell

curl --location 'https://nlp.aliyuncs.com/v2/api/common/file/asyn/upload' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-doc-converter-submit' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
    "sourceUrl":"公网可访问的xlsx文件url",
    "type":"excelToDocx"
    
}'

python

import json

import requests

api_key = "your-api-key"
service_name = "aca-doc-converter-submit"

url = "https://nlp.aliyuncs.com/v2/api/common/file/asyn/upload"
headers = {
    "Content-Type": "application/json",
    "x-fag-servicename": "aca-doc-converter-submit",
    "x-fag-appcode": "aca",
    "Authorization": f"Bearer {api_key}"
}

payload = {
     "sourceUrl":"公网可访问的xlsx文件url",
     "type":"excelToDocx"
}

response = requests.post(url, headers=headers, json=payload)

print(response.status_code)
print(json.loads(response.text))

excel转docx文件结果下载接口

HTTP接口

shell

curl --location 'https://nlp.aliyuncs.com/v2/api/common/file/asyn/download?taskId=xxx' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-doc-converter-result' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key'

python

import json

import requests

api_key = "your-api-key"
service_name = "aca-doc-converter-result"

url = "https://nlp.aliyuncs.com/v2/api/common/file/asyn/download"
headers = {
    "Content-Type": "application/json",
    "x-fag-servicename": "aca-doc-converter-result",
    "x-fag-appcode": "aca",
    "Authorization": f"Bearer {api_key}"
}

payload = {
    "taskId": xxx
}
response = requests.get(url, headers=headers, params=payload)

print(response.status_code)
print(json.loads(response.text))