Verification

Use this page when you want to know whether the MKG side works before you involve PHP. The two curl commands send the same requests the package sends.

Set the values in your shell

export MKG_HOST="your-mkg-host"
export MKG_CUSTOMER="your-api-key"
export MKG_USERNAME="your-api-username"
export MKG_PASSWORD="your-api-password"

export MKG_URL_AUTH="https://$MKG_HOST/mkg/static/auth/j_spring_security_check"
export MKG_URL_PROD="https://$MKG_HOST/mkg/web/v3/MKG/Documents"

For a training environment, replace /mkg/ with /mkgoefenclient/ in both URLs.

curl -sS -X POST "$MKG_URL_AUTH" \
  -H "X-CustomerID: $MKG_CUSTOMER" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "j_username=$MKG_USERNAME" \
  --data-urlencode "j_password=$MKG_PASSWORD" \
  --cookie-jar ./mkg-cookie.txt -D -

Expected: a Set-Cookie header that contains JSESSIONID. The cookie is saved in mkg-cookie.txt in the current directory. Delete the file when you are done; it is a live session.

2. Read five relations

curl -sS "$MKG_URL_PROD/rela?NumRows=5&FieldList=rela_num,rela_naam" \
  -H "Accept: application/json" \
  -H "X-CustomerID: $MKG_CUSTOMER" \
  --cookie ./mkg-cookie.txt

Expected: JSON with the rows under response.ResultData.

What the answer tells you

Answer Meaning
JSON with rows The host, the API key and the login are right. The same values work in .env.
403 with an HTML page The URL path is wrong. See Troubleshooting.
401 with {"status_code":401,"status_txt":"Not authenticated"} The cookie is missing or not valid. Run step 1 again and check the user name and the password.
A certificate error from curl The certificate of the host is not trusted by your machine. Add -k to test without verification, and see Troubleshooting for the package setting.

MKG’s own tools and documentation

MKG publishes a Postman collection and a public workspace: