Skip to content

Instantly share code, notes, and snippets.

@hongbo-miao
Last active February 18, 2021 12:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongbo-miao/bd85e0fe9ecf63644ba651eb226c2897 to your computer and use it in GitHub Desktop.
Save hongbo-miao/bd85e0fe9ecf63644ba651eb226c2897 to your computer and use it in GitHub Desktop.
Health Form

Version 2/18/2021

The script is for IT employees who work in Shanghai office.

Feel free to contact me if you have any questions.

How to use the script?

Step 1

curl --request POST \
  --url 'https://forms.office.com/formapi/api/9026c5f4-86d0-4b9f-bd39-b7d4d0fb4674/users/30adb388-4181-4469-9248-c9ad66869b9b/forms(%279MUmkNCGn0u9ObfU0PtGdIizrTCBQWlEkkjJrWaGm5tUN0k0Vkg3WEJNWVVETU82TldUWVBVM1Q2Ry4u%27)/responses' \
  --header 'content-type: application/json' \
  --data '{"answers":"[{\"questionId\":\"r042cf129d57f496b8afab255dae6d3d9\",\"answer1\":\"2021-02-xx\"},{\"questionId\":\"r24e3621acb4e4a4d982ef0acedfe97b1\",\"answer1\":\"王xx\"},{\"questionId\":\"r7dca155c5f5b49fd90cc9091b6a2a715\",\"answer1\":\"735xxx\"},{\"questionId\":\"r27e1b512dc8c42bcbc0413fb633d8d98\",\"answer1\":\"138xxxxxxxx\"},{\"questionId\":\"rfdc61b1d73224af98e6a9be52f1cae05\",\"answer1\":\"上海\"},{\"questionId\":\"r0a83ea4054a04b0fa7928c94ffeb4b58\",\"answer1\":null},{\"questionId\":\"rea0232b0d87645bda04717dfc12562f1\",\"answer1\":\"上海市浦东新区xx\"},{\"questionId\":\"ra2d519e57c684757a3545a0e4ddb7fa3\",\"answer1\":\"临港超级工厂/RDC       GFSH Factory /RDC\"},{\"questionId\":\"reb29d99ac45447578a899d09c6116eef\",\"answer1\":\"IT\"},{\"questionId\":\"r885303523ff246deba641027e42836ba\",\"answer1\":\"办公  Working\"},{\"questionId\":\"r7d3a49a252f1440e87c88b9cb2b94842\",\"answer1\":\"办公地点办公  Working in office\"},{\"questionId\":\"r40a5db0a38744cd5b6d0f807c22cd01a\",\"answer1\":\"体温正常,无感冒,无干咳   Normal temperature,No cold,No cough \"},{\"questionId\":\"r37e26505992f4b3ca0bfcbb85944433c\",\"answer1\":\"否No\"},{\"questionId\":\"r836c68e39e12473296f78a225dd0db3e\",\"answer1\":\"否No\"},{\"questionId\":\"rb3625560f6144d6d90c76db5083484b1\",\"answer1\":\"否No\"},{\"questionId\":\"r39b2e74b808248b8be2ce43e730709e8\",\"answer1\":\"本人承诺,以上个人健康及相关信息均由本人填写并承诺填写无误 I promise that the above personal health and related information will be filled in by me and promise to be correct\"}]"}'

Copy the script above out to a code editor, and update these fields in the script based on your own info.

  • 2021-02-xx -> Current date
  • 王xx -> Your name
  • 735xxx -> Your ID
  • 138xxxxxxxx -> Your phone
  • 上海 -> Your current city
  • 上海市浦东新区xx -> Your address

Step 2

Copy your updated script to the terminal and run.

Step 3

Next day, you only need to update

2021-02-xx -> New date

and run in the terminal again.

How to know whether succeed after submitting?

If you get a long response with the data you submitted inside after running the script, it succeed.

If failed, you will get a response like

{
  "error":{
    "code":"620","message":"Form schema mismatch. Inner Message: {\"error\":{\"code\":\"InvalidArgument\",\"message\":\"The request body did not contain a valid object\",\"innerError\":{\"code\":\"InvalidRequestBody\"}}}","@ms.form.error.type":"ExpectedFailure"
  }
}

Better user experience?

You can import the script to Insomnia or Postman.

They are more user friendly for updating the fields, and knowing whether the submission is succeed.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment