代表组织在 API 职位发布中链接,范围为 w_organization_social、w_member_social 、r_organization_social

问题描述 投票:0回答:1

我正在努力将 LinkedIn 的 API 集成到我的 React 应用程序中,以代表我们的组织发布职位。我已获得具有以下权限的访问令牌:

w_organization_social

w_member_social

r_organization_social

r_member_social

下面是我用于职位发布请求的请求标头和正文。

const config = {   headers: {     Authorization: `Bearer ${ACCESS_TOKEN}`,     "Content-Type": "application/json",     "LinkedIn-Version": "202401",     "x-restli-protocol-version": "2.0.0",   }, };
const requestBody = {   author: `urn:li:person:${PERSON_ID}`,   commentary: "Your job posting description here",   visibility: "PUBLIC",   distribution: {     feedDistribution: "MAIN_FEED",     targetEntities: [],     thirdPartyDistributionChannels: [],   },   lifecycleState: "PUBLISHED",   elements: [     {       integrationContext: `urn:li:organization:${ORG_ID}`,       companyApplyUrl: "https://cubiclogics.com",       externalJobPostingId: "12345",       jobPostingOperationType: "CREATE",       title: "Software Developer in Test",       description: "Your detailed job description here",       listedAt: Date.now(),       location: "Sunnyvale, California",       categories: ["rsch"],       industries: ["urn:li:industry:55"],       skillsDescription: "Required skills: JavaScript, Python, HTML/CSS",       companyJobCode: "company_12345",       employmentStatus: "FULL_TIME",       experienceLevel: "EXECUTIVE",       trackingPixelUrl: "http://www.trackingpixellocation.com/pixel.gif",       listingType: "BASIC",     },   ], };
//This is my code
async function postJobToLinkedIn() {
  try {
    let res = await axios.post(
      "https://api.linkedin.com/rest/posts",
      requestBody,
      config
    );
    console.log(res, "res from api");
  } catch (error) {
    console.error(
      "Error posting job:",
      error.response ? error.response.data : error.message
    );
  }
}
//Response
{
    "message": "ERROR :: /elements :: unrecognized field found but not allowed",
    "status": 422
}

我收到 422 状态错误,消息表明 /elements 字段无法识别。

我尝试过的:

  • 验证请求正文中的字段以确保它们与 LinkedIn 的文档。
  • 确保权限设置正确。
  • 检查LinkedIn最新的API更新,尤其是字段 与职位相关。
reactjs linkedin-api
1个回答
0
投票

事实上,用于发布职位的 LinkedIn API 不支持

elements
字段。
此外,职位发布应通过
/simpleJobPostings
端点发布,而不是
/posts

有关更多详细信息,请参阅LinkedIn 职位发布 API 文档

© www.soinside.com 2019 - 2024. All rights reserved.