HTTP Request to Supabase Edge Function returns “Missing or invalid query in body” although body is set

I’m trying to call a Supabase Edge Function from an n8n workflow, but the request keeps failing with a “Missing or invalid query in body” error.

Is this an authentication or body-format issue? Everything else in the automation works well.

Any help would be appreciated.

1 Like

Hey @Sanders_Rohling_Immo, that error is almost always about the Content-Type header not being set to `application/json` or the body not being valid JSON. Supabase Edge Functions expect the body to come through as proper JSON, not form data or a string. In the HTTP Request node make sure you’re using “JSON” as the body content type (not “Raw” or “Form”), and if you’re building the body manually double check it’s actually an object with a `query` key or whatever your edge function expects. Also worth checking that the body isn’t accidentally getting stringified twice which happens sometimes if you’re passing output from another node that’s already a string.

Hey @achamm , thanks for your help.

that error is almost always about the Content-Type header not being set to application/json

This should not be the issue.

This is my JSON input:

{
“query_text”: “{{ $(‘When Executed by Another Workflow’).item.json.query }}”,
“query_embedding”: [{{ $json.data[0].embedding }}],
“match_count”: 5,
“full_text_weight”: 1.0,
“semantic_weight”: 1.0,
“rrf_k”: 50
}

And this is the result → I am not sure if this is correct:

{
“query_text”: “was muss ich reinigen”,
“query_embedding”: [0.01610721,-0.0033309269,-0.027216487,0.005134019,-0.01871752,-0.0025824734,-0.0068226783,0.039364934,-0.020845354,0.04401648,0.044511326,-0.012160821,0.005941235,0.009463915,0.012445357,0.011610306,0.028107207,0.003383504,-0.054334003,0.06086596,-0.016156696,0.018037107,0.005548452,-0.009092781,-0.033179373,0.0039742254,0.0146103045,-0.04114638,0.043670088,0.0007681699,-0.012129893,-0.036989678,-0.0064886576,-0.019076282,0.02518762,-0.0025762878,-0.006145359,-0.039439164,-0.017109273,0.024024734,-0.010608244,-0.0044845347,0.033327825,-0.042185552,0.024878342,-0.017999994,-0.027612362,0.024148446,-0.00919175,-0.039142255,0.0049979365,-0.015587624,0.024828859,0.06061854,0.032115452,-0.015402057,0.0033958752,0.013410305,-0.0449072,0.051166993,0.01796288,0.0023737105,-0.024680404,0.003596906,-0.043298956,0.016243294,0.019892776,0.058144312,-0.005344328,-0.036197927,0.016985562,-0.011999996,-0.030408237,-0.044065963,-0.043298956,-0.07209895,0.031002052,-0.040008236,-0.0055113384,0.054482456,-0.03075463,-0.029987618,-0.025484528,0.0051494827,-0.0069030905,0.0014126285,0.07971956,-0.0059381425,-0.0076515437,0.0035195865,-0.034094833,0.019101026,-0.0006189431,-0.038820606,-0.0112639135,-0.008919585,-0.013731955,0.00913608,-0.0065938123,0.005839173,0.040997926,-0.084766984,0.016589686,-0.015414428,0.0444371,-0.028923701,-0.050523695,-0.030581433,-0.037286587,0.009630925,-0.012488656,-0.0067051523,0.003213401,-0.012618553,0.013707212,0.010131955,0.015426799,-0.046663903,-0.057649467,-0.05220617,0.037608236,0.030408237,-0.030927826,-0.013521645,-0.027736073,-0.011319584,0.050301015,-0.041690707,-0.0009865976,-0.0071319565,0.015909273,-0.046020605,0.018334014,-0.009210306,-0.030606175,0.033129886,0.039562874,0.059628848,-0.01488247,0.0076020593,0.04772782,0.017294839,0.021080406,-0.024816487,-0.03812782,-0.023715457,0.041195862,-0.0133731915,0.008301028,-0.024482466,-0.03973607,-0.0112268,0.012340202,0.0013724222,-0.037583493,-0.016589686,0.027414424,0.015167005,0.0057494827,-0.0010716491,-0.03216494,-0.003937112,-0.02682061,-0.053938128,0.014065974,-0.0015749995,0.024890713,-0.010311337,-0.00080798945,0.024668034,-0.03785566,0.02649896,0.045575242,0.00920412,-0.041566998,0.009544327,-0.032387618,0.030284526,-0.041690707,0.008319585,-0.008338141,0.020301023,0.013632986,-0.03327834,-0.07190101,0.024581436,0.00095103064,0.030037103,-0.057154622,0.030259784,-0.031892773,0.010496904,0.010045358,0.020338139,0.009686595,-0.011944326,0.014437108,-0.03755875,-0.00039548957,0.012439171,-0.010973193,-0.028082466,-0.0051030912,0.008430925,-0.03350102,0.02101855,-0.043076273,-0.017789684,-0.025979374,-0.023059787,0.04136906,0.012340202,-0.10243296,0.032140195,0.0012185563,0.01905154,0.034639165,-0.025459785,-0.02354226,-0.015352572,-0.0053226785,0.026251538,0.030408237,0.02934432,-0.0025670095,-0.03701442,0.0674474,-0.007806183,0.024383496,0.0009896904,-0.04312576,0.0153896855,-0.035430916,-0.024556693,-0.0117649445,0.04654019,-0.07209895,0.013917522,0.011931955,0.01144948,-0.03733607,-0.0016175252,0.029863907,-0.007886595,-0.0088762855,0.014857727,0.0012641748,0.0095628835,-0.015055665,-0.00012931696,-0.01796288,-0.027315455,0.017270098,-0.024668034,-0.018729892,0.0069340183,-0.02057319,0.024148446,0.042655658,0.009117523,-0.026845353,0.005727833,-0.04522885,-0.06353813,-0.01198144,0.030037103,-0.0018216489,-0.014820614,-0.005344328,-0.03681648,-0.040008236,-0.0218969,-0.006995874,0.0040731947,-0.047999986,-0.0014164944,0.022725767,0.0049824724,0.039142255,-0.00898144,-0.0751175,-0.022812365,0.027513392,0.0027912362,-0.05091957,0.064379364,0.019187622,-0.009934017,0.009123708,0.03592576,0.004663916,-0.011684532,0.0071010287,0.0224536,-0.025657725,-0.030507207,0.0100268,-0.023517517,-0.009816492,-0.016305149,-0.013101026,0.02210721,0.0041164937,0.03285772,-0.026647415,0.021414425,0.06804121,-0.050969057,0.03337731,-0.031595867,-0.015884532,-0.015426799,-0.0013221645,-0.05059792,0.02978968,-0.03392164,-0.012903089,0.022206178,0.039810296,-0.045278337,0.054531943,0.002454123,0.010886595,-0.0024061848,-0.0069402037,0.009408244,-0.010193811,0.024940198,-0.011758759,-0.025855662,-0.014214428,0.0059783487,0.019670097,0.011195873,0.046020605,0.010032986,-0.0036185556,-0.032090712,0.014498964,-0.030160815,-0.0127298925,-0.030284526,0.013632986,0.039884523,-0.033995867,0.04522885,0.02012783,-0.03340205,0.028230919,0.020090716,0.0112639135,0.052503075,-0.0073979357,-0.030235041,-0.010595873,0.05388864,-0.0016298963,0.027711332,-0.022131952,0.0008365977,0.05769895,0.009167007,0.0027170095,0.012173192,0.036470093,0.052701015,-0.0094701,0.028156692,-0.027191743,0.05967833,-0.013781439,-0.027736073,0.026696898,-0.0031608238,-0.048247408,0.0013608243,0.025360817,0.0056319567,-0.02244123,-0.031026794,0.01642886,-0.027191743,-0.026795868,-0.032585558,0.020004118,-0.025039168,-0.009810306,0.020771127,0.020202056,0.0042556687,0.069575235,-0.019534014,0.0420371,0.042952564,0.04423916,-0.007261853,0.017975252,0.06601235,-0.07190101,-0.033971123,0.016057726,-0.0029938135,0.0051092766,0.03295669,-0.030086588,0.03164535,-0.024235044,-0.043744314,0.030680403,-0.06665565,-0.0008791234,0.059183486,0.05591751,0.06764534,-0.00075270596,-0.03456494,0.05121648,0.004577318,0.0016051541,-0.022156693,0.018296901,0.024655662,-0.068189666,-0.028874217,0.041789677,0.013447419,-0.025336074,0.02659793,0.010991749,-0.021315457,-0.053492766,-0.017369067,0.0048402045,-0.018680407,-0.009030925,-0.09144739,-0.021921642,-0.021030921,-0.020511333,-0.019397931,-0.014461851,0.0031438135,-0.0026072157,0.025026796,-0.02704329,-0.0048463903,-0.019830922,0.021513395,-0.031892773,0.003197937,-0.018841231,-0.027958754,-0.014622675,-0.0260536,0.03481236,-0.036173183,-0.012402058,-0.018742261,0.0002853092,0.00015164299,0.008764946,0.03392164,0.0066865957,0.03446597,0.025435043,0.08051132,-0.03491133,0.023517517,0.041764934,-0.05834225,0.0033494835,0.005734019,-0.0052917507,-0.0043855654,-0.037039164,-0.038919576,-0.0047690705,0.013744325,0.007150513,-0.040032975,-0.05482885,-0.062004104,-0.031051537,-0.03285772,-0.0019097932,0.09025977,-0.0401072,0.027513392,-0.092536055,-0.022725767,0.0017922674,0.022861848,-0.041566998,-0.012216491,-0.0060649463,-0.032239165,-0.02266391,-0.014028861,0.007484534,0.00087989663,0.005245359,0.032041226,0.009265976,0.071999975,0.037261844,-0.01991752,0.049632974,-0.007719585,0.030408237,-0.04369483,-0.023715457,0.010428863,0.000085389795,-0.001150515,-0.02232989,0.026647415,-0.0039587617,-0.01895257,-0.009439172,0.03523298,0.023567002,0.014783501,0.032981433,-0.0090123685,0.009705151,-0.030729886,-0.026969064,-0.05878761,-0.016218552,-0.024222672,-0.0077876262,0.00018150767,-0.026672157,-0.00836907,0.0027726796,0.016725767,-0.016923705,0.024358755,-0.0051030912,0.030012362,0.06452782,-0.0038659782,-0.02244123,-0.048024725,0.0396371,0.011758759,0.031447414,-0.013942263,0.0218969,0.021204118,0.026969064,-0.008084534,-0.017789684,0.0055824723,0.039364934,-0.0155752525,0.01937319,-0.004005153,0.026548445,-0.016057726,-0.008870101,-0.011845357,0.03733607,-0.0016252572,-0.027117517,-0.016478345,-0.0133731915,-0.023641229,0.00073298946,-0.019348448,-0.0012719068,-0.02746391,0.0041319574,-0.023022672,0.009123708,0.018309273,0.00023969065,-0.022837106,-0.031595867,-0.011870099,-0.01675051,-0.035109267,0.018136077,-0.012754635,-0.0066804104,-0.009160821,0.05779792,-0.017579377,0.01905154,-0.034119576,0.034762874,-0.011696903,0.031125763,0.0006112111,0.008406183,0.044090707,-0.016094841,0.02289896,0.024148446,-0.007806183,0.027859785,0.014251541,-0.013410305,-0.020585561,0.031892773,0.0015479376,0.028602052,0.008356699,0.008059791,0.03110102,0.00040244832,0.011511336,0.032387618,-0.0049855653,-0.0060030906,-0.0028175248,-0.011375254,-0.010620615,0.003955669,0.008727833,-0.0062257713,-0.009364946,0.030828856,-0.007874224,0.0030402052,0.009655667,-0.03525772,-0.023059787,-0.036519576,0.027092775,-0.031274218,-0.00527938,0.04520411,-0.019571127,0.018222675,0.034861844,0.04391751,-0.0034762875,-0.0023737105,-0.005403091,0.017987624,-0.032981433,0.03874638,-0.0051556686,0.04752988,0.0569072,0.01992989,0.01795051,-0.0037701018,-0.027785558,-0.04819792,0.0067051523,0.0022855662,-0.010311337,0.016701026,0.04357112,0.006071132,0.0159835,-0.029839166,-0.028156692,0.044065963,-0.0014876284,0.015859788,0.01905154,-0.00094948424,-0.021402055,0.0028824734,-0.031670094,-0.02232989,0.029319579,0.056461837,0.01631752,0.027686588,-0.01489484,0.05131545,-0.011665976,0.0046113385,-0.019199993,0.0018448448,0.0040175244,-0.009098967,-0.01981855,-0.018989684,0.019002056,-0.018259788,-0.010762883,0.0078185545,-0.02112989,-0.019039169,0.048420604,-0.023925766,-0.039909266,0.0033216483,0.024470095,0.03921648,0.06051957,-0.0150680365,0.0020381436,-0.0006792524,-0.015451541,-0.029294835,-0.017208243,-0.021080406,-0.043298956,0.028750505,0.014202057,0.040008236,0.029022671,0.02289896,0.002916494,0.019620612,0.034688648,-0.009550513,-0.021661848,-0.0048958748,-0.007954637,0.021204118,0.0036618544,0.023232982,-0.002636597,0.0023103086,-0.012228862,0.019150509,-0.04641648,0.037385553,-0.0200536,-0.030729886,0.0024788652,-0.026375249,0.0031670092,0.0116288625,-0.033179373,-0.0027293805,0.025212362,0.0008999997,0.017121645,0.01850721,-0.00023969065,-0.004298968,-0.04587215,-0.031002052,-0.0074721626,0.014065974,0.00539072,-0.046441223,-0.025385559,0.05948039,0.035752565,-0.025558755,0.0043175244,-0.0120865945,0.009043296,-0.019880407,0.0047814418,0.0019469066,-0.037682462,-0.013199996,0.007855668,0.0063525755,-0.022305148,0.009606183,0.048123695,-0.0023999992,0.015476284,-0.0030185557,0.005347421,-0.012890718,0.0053010294,0.02012783,-0.025806177,0.016045356,-0.025435043,0.017542262,-0.023938136,0.0032319578,-0.023876281,-0.010478348,-0.015884532,-0.035381433,-0.00034329886,-0.031694837,0.008041235,0.0051494827,0.02407422,-0.019348448,-0.041962873,0.011202058,0.030284526,0.027760815,-0.03491133,-0.0003187499,-0.024692776,0.033971123,-0.0027262878,-0.010045358,-0.0080969045,0.010323708,0.09317935,0.014498964,-0.004527834,-0.005434019,-0.03602473,-0.008239172,0.019323705,0.021538137,-0.026523704,0.028107207,-0.00020257726,-0.005362885,-0.006544328,0.05383916,0.02210721,-0.017752571,0.0284536,-0.006995874,0.016181437,0.027167002,-0.032189682,0.039265968,-0.037459783,-0.0005918812,-0.04062679,-0.022960817,0.00022403343,0.0071999975,-0.005941235,-0.000106894295,-0.0019036076,0.0037329884,-0.040552564,-0.019645354,-0.015797934,-0.014065974,0.007255668,-0.001581185,0.0021061848,-0.009129894,-0.007478348,-0.031620607,-0.03424329,-0.03461442,-0.02912164,0.029022671,-0.0066865957,-0.019546386,0.006884534,-0.002418556,-0.027340198,0.020350508,0.022144323,-0.018556695,0.009247419,0.017232984,-0.02179793,0.005304122,0.0042123697,0.04696081,0.019360818,0.00095798937,0.0025067,-0.039711326,0.04334844,0.0018092778,-0.050301015,0.005427833,-0.027315455,-0.025929889,-0.017171128,-0.0001764819,-0.044610295,-0.0075340183,0.0026969064,0.008468038,-0.008127833,0.024692776,0.022206178,0.010509275,0.020486591,0.013076285,-0.025459785,-0.0021618549,-0.00071597914,-0.014387624,-0.020548446,-0.026226796,-0.043942254,-0.017059788,0.0075835027,-0.010769068,0.013039171,-0.028725764,0.015946386,0.018544324,-0.014177315,0.014004119,-0.020721642,0.012556697,0.019558756,0.018136077,-0.0042556687,-0.036074214,-0.00082268013,0.0007631441,0.018482469,-0.019694839,0.0066742245,0.017096901,0.006556699,-0.029517516,-0.02299793,0.04421442,0.016503088,-0.01324948,-0.029962877,0.023802055,-0.0064886576,-0.007138142,0.010632986,-0.006779379,0.021179374,-0.020498963,0.006482472,0.0010422677,-0.025039168,0.055373177,-0.005619586,-0.0038566997,0.03446597,0.014140202,-0.012111336,0.030061847,-0.026870094,-0.028404115,0.018012365,0.00012264815,0.0028484527,0.027315455,-0.018668035,-0.01871752,-0.004651545,0.011232986,-0.04389277,0.0027432982,-0.020399993,0.005245359,-0.019435044,0.005062885,-0.008059791,-0.028824734,0.017604118,0.013558758,-0.027389681,0.0033587618,-0.034193803,-0.017393809,-0.025101023,0.019002056,-0.008146389,-0.000089207446,0.010373193,-0.008307214,-0.02232989,0.01555051,0.0024881435,0.044313386,-0.010292781,-0.055323694,0.02924535,-0.010608244,0.030012362,-0.040280398,0.0076577296,-0.034169063,0.024841229,0.003609277,0.0141525725,-0.010453605,0.014189686,0.015847418,0.0014296387,0.0124268,-0.0106639145,0.06343915,0.00061237096,0.0024371126,0.027315455,0.043175243,-0.03456494,-0.020622674,-0.039265968,-0.028503083,0.032387618,-0.026969064,0.03065566,0.01882886,-0.006773194,0.003995875,-0.01960824,-0.0114432955,0.02748865,-0.0044845347,0.025830919,-0.0004948452,0.010521646,-0.023294838,0.016564943,-0.025558755,0.010144327,-0.023059787,0.0039865966,0.03775669,0.031472154,0.011938141,-0.019979374,-0.019744324,-0.0035938132,0.026474219,0.03461442,0.0035103082,0.010045358,0.033105142,-0.035059784,0.016441232,-0.018259788,0.025657725,0.0080041215,0.0356536,0.03456494,-0.014585562,-0.00134768,0.005242266,0.027983496,0.014647418,-0.0066927816,0.024531951,0.0021201025,-0.0041412357,-0.016911335,-0.0063773175,0.0116721615,0.0278103,0.013496903,-0.017146386,-0.033550505,0.0030572156,0.008134018,-0.015847418,0.037608236,-0.015934015,0.0050566993,0.029072156,0.014721645,0.015909273,0.029913392,-0.005718555,0.002802061,-0.015946386,0.009940203,-0.023690714,-0.016292779,-0.008802059,0.00084432965,0.0014605665,-0.0072865956,-0.017492779,-0.028379371,-0.04020617,0.028552568,-0.01347216,-0.008764946,-0.009661852,0.0033061844,0.025781436,-0.0077010286,-0.018197933,-0.0040298956,-0.04127009,0.009692781,-0.0131876245,0.015228861,0.010329894,0.030061847,-0.015018552,0.0073113376,0.017505148,0.010793811,0.0058515444,-0.026375249,-0.024395868,-0.004710308,0.02124123,0.016589686,0.027760815,-0.0035103082,0.0013237109,0.021810303,0.010521646,0.003797937,0.02790927,0.0001583118,0.0059783487,0.01347216,-0.026622672,-0.019496901,-0.0014002572,0.012692779,-0.0052701016,0.003454638,0.009674224,0.0073917503,0.053344313,0.0036958752,-0.025880404,-0.007750513,-0.0019082468,0.013670099,0.017010303,0.0027262878,-0.026399992,0.0022824735,0.0009572162,-0.008115461,-0.036841225,-0.0038505143,-0.016824737,-0.007367008,-0.006921647,-0.008152574,0.014387624,-0.04290308,-0.013162882,0.012340202,0.06601235,-0.011257729,0.0010043811,-0.014399995,0.018445354,-0.01927422,-0.008053605,-0.018841231,0.019422675,-0.0038072153,-0.008307214,0.0065072146,-0.0020768035,0.0040577305,0.006668039,0.083579354,-0.013051542,-0.01368247,-0.021204118,-0.016342264,-0.0020164943,-0.0046113385,0.0037298957,0.020103086,0.016020613,-0.020090716,0.044857718,-0.01576082,0.003596906,-0.025459785,-0.01728247,-0.024383496,-0.008882471,-0.0128659755,0.0068350495,-0.042779367,0.01105979,-0.020498963,-0.02988865,-0.022206178,-0.021080406,-0.010329894,0.011232986,0.055373177,0.006253606,0.03622267,-0.0068288636,-0.028329888,0.027340198,0.013125769,-0.0011273192,0.039439164,0.015896901,-0.012705151,-0.040676277,0.020486591,0.0056072148,-0.0013268037,0.025781436,0.014164944,0.022020612,-0.017814428,0.04960823,0.0024077313,-0.01730721,0.01673814,0.02046185,0.008430925,-0.010917522,-0.008127833,-0.050870087,0.007422678,0.0027340197,0.02758762,0.004521648,-0.039983492,-0.017678345,0.0028237104,-0.005059792,-0.027637104,0.010911337,-0.021748446,-0.007663915,0.01895257,-0.041665968,-0.0052206167,-0.009822677,0.009828863,0.03154638,-0.0027773187,0.04050308,0.013261852,-0.019002056,0.022676282,-0.035480402,0.0053226785,-0.00041365967,-0.014338139,-0.0026056692,0.019039169,-0.009018553,0.0060092765,0.039166998,0.0046268026,-0.0032381434,-0.023195868,0.028107207,-0.005087627,-0.012334017,0.020437106,-0.00063556683,-0.015847418,-0.002130927,0.028651537,-0.012977315,0.014090717,-0.0092907185,0.0056103077,-0.0016747417,-0.0062659774,0.023703085,-0.026177311,0.019397931,-0.007478348,0.031397928,0.03785566,-0.019026797,0.008820616,-0.028008237,-0.038053595,-0.05091957,0.025558755,-0.03832576,0.017369067,-0.0058237095,0.010936079,-0.009785564,0.020041231,0.02375257,-0.033872154,-0.04849483,0.012569068,0.016391747,0.027439166,0.007973193,0.016713398,-0.011505151,0.017492779,0.015018552,-0.017876282,-0.010645357,0.010329894,-0.013237109,-0.004636081,-0.02889896,0.035480402,0.022193808,0.037929885,0.029938135,0.014338139,0.013261852,-0.017146386,0.0030494835,-0.016503088,0.030606175,0.016465975,0.0019097932,-0.0032350505,0.009111337,0.008437111,0.021092776,-0.0039494834,0.013125769,0.010670099,0.0046113385,-0.011468038,-0.0149319535,0.0030572156,0.0034855658,0.028008237,0.0025005147,-0.019632984,0.0025577312,-0.018049479,-0.010849481,-0.008597936,0.02464329,0.0061917505,0.034639165,-0.012154635,0.02464329,-0.0015819583,0.010855666,0.025880404,0.014597934,0.051711325,0.020647416,-0.035010297,0.018593809,0.012030924,-0.023195868,-0.020140199,-0.0066618538,0.02704329,-0.017220613,0.03337731,-0.021748446,0.0010298965,0.019336076,0.040428855,0.014585562,0.014004119,-0.002959793,-0.0009672677,-0.010367007,-0.010212367,-0.044164933,-0.0019175252,-0.0062257713,0.0011451027,0.010051543,-0.035752565,-0.02231752,-0.0025175249,0.027241228,-0.01631752,0.004821648,-0.020387622,0.026103085,0.023468034,0.00024626282,-0.0073051522,0.004184535,0.00838144,-0.009457729,-0.05230514,-0.053146373,-0.033550505,-0.029047413,-0.028156692,-0.013917522,-0.030630918,-0.038597926,0.029740196,-0.008022678,0.041096892,-0.0036340195,-0.004892782,-0.015154635,0.0011721646,0.047777303,-0.025051538,0.0102989655,-0.05923297,0.024828859,-0.0034886587,0.02649896,0.017393809,-0.0019778344,-0.022404116,-0.016243294,-0.01345979,-0.0009989687,-0.025756693,0.024012363,0.03951339,0.010799997,0.010595873,0.031249475,-0.047851533,-0.01840824,0.007484534,-0.025336074,0.021364942,-0.0230969,0.018074222,0.049979366,-0.00017155278,-0.00213402,-0.02276288,-0.037632976,-0.013360821,0.016280407,0.021080406,-0.020276282,-0.0004430411,-0.03822679,-0.032115452,-0.018098963,-0.003482473,0.0178268,-0.0039865966,0.013014429,0.017356696,-0.0038566997,-0.00095953577,0.021154633,0.011777316,-0.030853597,0.008171132,-0.00036088907,0.018754633,0.010317522,0.015265974,0.0043329885,-0.004963916,0.015463913,-0.014808242,0.038795862,-0.0016824737,-0.007268039,-0.0473072,-0.015340202,-0.018148448,-0.037731946,0.045154624,-0.025979374,0.0073484513,-0.00892577,0.02790927,0.0050010295,-0.0070886575,-0.01673814,0.020659788,0.03285772,-0.009346388,-0.01860618,0.028973186,-0.024692776,-0.012841233,0.042284522,0.00025844065,-0.010540203,0.014115459,-0.0073113376,0.0012889171,0.032090712,0.021179374,0.008084534,-0.0776907,-0.016688654,-0.04127009,-0.03194226,0.01707216,0.004382473,-0.017789684,-0.012340202,-0.04124535,0.011301028,-0.0060061836,-0.02244123,-0.0171835,-0.0039432975,-0.022960817,-0.017715458,-0.0029860814,-0.00079948426,-0.008010306,-0.016305149,-0.012538141,0.0037762874,0.018482469,-0.00044884006,0.016329892,-0.018964943,-0.018865973,0.0048030913,0.0066371113,-0.0063525755,-0.002616494,0.0035814422,0.021958755,-0.019187622,-0.046688646,0.027414424,-0.031026794,0.004939174,-0.02464329,-0.0009626286,-0.021859787,0.021488653,-0.0051835035,-0.020523705,-0.0058979364,0.0092412345,-0.016812366,-0.008437111,-0.0024092775,-0.037088647,-0.0038721636,-0.0070453584,0.029369062,0.0007631441,-0.005384534,0.010113399,0.039018545,0.0044567,-0.0019561849,-0.0029458753,0.04136906,-0.0015695872,0.01100412,-0.025707208,0.016577315],
“match_count”: 5,
“full_text_weight”: 1.0,
“semantic_weight”: 1.0,
“rrf_k”: 50
}

double check it’s actually an object with a query key or whatever your edge function expects.

How exactly do I check this?

@Sanders_Rohling_Immo

Looking at your workflow again, the body you’re sending has query_text as the field name but the error specifically says “Missing or invalid query in body” which usually means your edge function code is looking for a field called query not query_text. Can you open your edge function code on Supabase and check what it’s destructuring from the request body? It’s probably doing something like const { query } = await req.json() and since you’re sending query_text instead of query it comes back as undefined and throws that error. If that’s the case just rename query_text to query in your HTTP Request body and it should work.

1 Like

I kept the JSON and reowrked the supabase edge function.

I switched from this:

import { createClient } from ‘npm:@supabase/[email protected]’;

// Edge Function: match-docs-api
// Expects POST JSON body: { query: string, k?: number, filter?: object }
// Calls the Postgres function: match_documentshs_hybrid(query text, k int default 5, filter jsonb default ‘{}’)

const SUPABASE_URL = Deno.env.get(‘SUPABASE_URL’) || ‘’;
const SUPABASE_SERVICE_ROLE_KEY = Deno.env.get(‘SUPABASE_SERVICE_ROLE_KEY’) || ‘’;

if (!SUPABASE_URL || !SUPABASE_SERVICE_ROLE_KEY) {
console.error(‘Missing SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY’);
}

const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
auth: { persistSession: false },
});

Deno.serve(async (req: Request) => {
try {
if (req.method !== ‘POST’) {
return new Response(JSON.stringify({ error: ‘Method not allowed, use POST’ }), { status: 405, headers: { ‘Content-Type’: ‘application/json’ } });
}

const contentType = req.headers.get('content-type') || '';
if (!contentType.includes('application/json')) {
  return new Response(JSON.stringify({ error: 'Content-Type must be application/json' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
}

const body = await req.json();
const query = body.query;
if (!query || typeof query !== 'string') {
  return new Response(JSON.stringify({ error: 'Missing or invalid `query` in body' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
}

const k = typeof body.k === 'number' ? body.k : 5;
const filter = body.filter ? body.filter : {};

// Call Postgres function
const sql = `select * from match_documentshs_hybrid($1::text, $2::int, $3::jsonb)`;
const { data, error } = await supabase.rpc('match_documentshs_hybrid', { query: query, k: k, filter: filter });

// NOTE: Using rpc may be preferable; fallback to SQL if rpc fails
if (error) {
  // try raw SQL
  const res = await supabase
    .rpc('match_documentshs_hybrid', { query: query, k: k, filter: filter });
  if (res.error) {
    return new Response(JSON.stringify({ error: res.error.message }), { status: 500, headers: { 'Content-Type': 'application/json' } });
  }
  return new Response(JSON.stringify({ result: res.data }), { status: 200, headers: { 'Content-Type': 'application/json' } });
}

return new Response(JSON.stringify({ result: data }), { status: 200, headers: { 'Content-Type': 'application/json' } });

} catch (err) {
console.error(err);
return new Response(JSON.stringify({ error: err.message ?? String(err) }), { status: 500, headers: { ‘Content-Type’: ‘application/json’ } });
}
});

to this:

import { createClient } from ‘npm:@supabase/[email protected]’;

// Edge Function: match-docs-api

// Expects POST JSON body:

// {

// query_embedding: number,

// query_text: string,

// match_count?: number

// }

// Calls the Postgres function:

// match_documentshs_hybrid(query_embedding real, query_text text, match_count integer)

const SUPABASE_URL = Deno.env.get(‘SUPABASE_URL’) || ‘’;

const SUPABASE_SERVICE_ROLE_KEY = Deno.env.get(‘SUPABASE_SERVICE_ROLE_KEY’) || ‘’;

if (!SUPABASE_URL || !SUPABASE_SERVICE_ROLE_KEY) {

console.error(‘Missing SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY’);

}

const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {

auth: { persistSession: false },

});

Deno.serve(async (req: Request) => {

try {

if (req.method !== 'POST') {

  return new Response(JSON.stringify({ error: 'Method not allowed, use POST' }), {

    status: 405,

    headers: { 'Content-Type': 'application/json' },

  });

}



const contentType = req.headers.get('content-type') || '';

if (!contentType.includes('application/json')) {

  return new Response(JSON.stringify({ error: 'Content-Type must be application/json' }), {

    status: 400,

    headers: { 'Content-Type': 'application/json' },

  });

}



const body = await req.json();



const query_embedding = body.query_embedding;

const query_text = body.query_text;

const match_count =

  typeof body.match_count === 'number' ? body.match_count : 5;



if (!query_text || typeof query_text !== 'string') {

  return new Response(JSON.stringify({ error: 'Missing or invalid query_text' }), {

    status: 400,

    headers: { 'Content-Type': 'application/json' },

  });

}



if (!Array.isArray(query_embedding)) {

  return new Response(JSON.stringify({ error: 'Missing or invalid query_embedding' }), {

    status: 400,

    headers: { 'Content-Type': 'application/json' },

  });

}



const { data, error } = await supabase.rpc('match_documentshs_hybrid', {

  query_embedding: query_embedding,

  query_text: query_text,

  match_count: match_count,

});



if (error) {

  return new Response(JSON.stringify({ error: error.message }), {

    status: 500,

    headers: { 'Content-Type': 'application/json' },

  });

}



return new Response(JSON.stringify({ result: data }), {

  status: 200,

  headers: { 'Content-Type': 'application/json' },

});

} catch (err) {

console.error(err);

return new Response(JSON.stringify({ error: err.message ?? String(err) }), {

  status: 500,

  headers: { 'Content-Type': 'application/json' },

});

}

});