Chilkat Online Tools

PowerBuilder / MeiliSearch v0.24 / Update ranking rules

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Jarr
oleobject loo_SbRequestBody
oleobject loo_Resp

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// [
//   "typo"
// ]

loo_Jarr = create oleobject
li_rc = loo_Jarr.ConnectToNewObject("Chilkat_9_5_0.JsonArray")

loo_Jarr.AddStringAt(-1,"typo")

loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("X-Meili-Api-Key","masterKey")

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Jarr.EmitSb(loo_SbRequestBody)

loo_Resp = loo_Http.PTextSb("POST","http://localhost:7700/indexes/indexUID/settings/ranking-rules",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Jarr
    destroy loo_SbRequestBody
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Jarr
destroy loo_SbRequestBody

Curl Command

curl -X POST
	-H "X-Meili-Api-Key: masterKey"
	-H "Content-Type: application/json"
	-d '[
	"typo"
]'
http://localhost:7700/indexes/indexUID/settings/ranking-rules

Postman Collection Item JSON

{
  "name": "Update ranking rules",
  "protocolProfileBehavior": {
    "disabledSystemHeaders": {
      "content-type": true
    }
  },
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "[\n\t\"typo\"\n]\n"
    },
    "url": {
      "raw": "{{url}}/indexes/{{indexUID}}/settings/ranking-rules",
      "host": [
        "{{url}}"
      ],
      "path": [
        "indexes",
        "{{indexUID}}",
        "settings",
        "ranking-rules"
      ]
    }
  },
  "response": [
  ]
}