在端点 URL 中添加变量值

Adding a variable value in endpoint URL

我正在尝试将联系人 ID 作为参数传递给其中一个 Web 服务,并获取要在帐户对象中更新的值。但我无法将联系人记录 ID 字段设置为端点参数 URL。

List<Contact> ContactUpdate = [SELECT id  FROM Contact where Rep__c like 'CRM%'];
     String ContactID;
     HttpRequest req = new HttpRequest();
     req.setTimeout(60000); 
     req.setHeader('Accept','*/*');
     req.setHeader('Content-Type','application/json'); // Content Type
     req.setMethod('GET'); 
     for (Contact c : ContactUpdate)
     {    
     ContactID = c.id;
     req.setEndpoint('https://xxx/xxxx/xxxxx/xxx/xxx-lookup? ContactID= {! ContactID});

     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getBody());

        JSONParser parser = JSON.createParser(res.getBody());

        String GMMID;
        while (parser.nextToken() != null) {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && 
                (parser.getText() == 'GCGMM')) {
                // Get the value.
                parser.nextToken();
                // Compute the grand total price for all invoices.
                GMMID = parser.gettext();
            }
        }
        //ContactUpdate.IsFutureContext__c = true;
        C.Group_ID__c = GMMID;
        update c;
        }

有人可以指导我在端点 URL 中添加变量作为参数吗?

尝试使用正文并将其从端点中删除。

String body = 'ContactID=' + contactID;
req.setbody(body);