Raw POST to the MISP server

        :param path: URL fragment (ie /events/)
        :param body: HTTP Body (raw bytes)
        :returns: HTTP raw content (as seen by :class:`requests.Response`)
496848
def POST(self, path, body, xml=True):
        
        url = self._absolute_url(path)
        headers = dict(self.headers)
        if xml:
            headers['Content-Type'] = 'application/xml'
            headers['Accept'] = 'application/xml'
        else:
            headers['Content-Type'] = 'application/json'
            headers['Accept'] = 'application/json'

        resp = requests.post(url, data=body, headers=headers, verify=self.verify_ssl)
        if resp.status_code != 200:
            raise MispTransportError('POST %s: returned status=%d', path, resp.status_code)
        return resp.content
645621
def post(path, body = '', headers = {})
      headers = { 'Content-Type' => 'application/json' }.merge(headers)
      request(:post, path, body, merge_default_headers(headers))
    end
67262
def post(self, path, data):
        
        LOGGER.debug('Posting data: %r', data)
        return self.session.post(self._request_url(path),
                                 data=json.dumps(data or {}),
                                 headers=self.HEADERS, auth=self.auth,
                                 verify=False)
1154891
def get(path, params={})
      dont_parse_response = params.delete(:dont_parse_response)

      options = {
        :content_type => :json, 
        :accept => :json, 
        :params => params.merge(:apikey => @api_key, :source => @source)
      }

      RestClient.get("#{@litmosURL}/#{path}", options) do |response, request, result|
        case response.code
        when 200, 201 
          # 200 Success. User/Course etc updated, deleted or retrieved
          # 201 Success. User/Course etc created
          if response.blank?
            true
          else
            if dont_parse_response
              response
            else
              parse_response(response)
            end
          end
        when 404 # 404 Not Found. The User/Course etc that you requested does not exist
          raise NotFound.new(response)

        else
          # 400 Bad Request. Check that your Uri and request body is well formed
          # 403 Forbidden. Check your API key, HTTPS setting, Source parameter etc
          # 409 Conflict. Often occurs when trying to create an item that already exists
          raise ApiError.new(response)

        end        
      end
    end
1304511
public JSONObject post(String path, JSONObject content, Map<String,String> headers)
            throws ServiceException, JSONException {
        String sub = getSegment(path, 4);
        if ("event".equals(sub)) {
            SlackEvent event = new SlackEvent(content);
            EventHandler eventHandler = getEventHandler(event.getType(), event);
            if (eventHandler == null) {
                throw new ServiceException("Unsupported handler type: " + event.getType()
                        + (event.getChannel() == null ? "" : (":" + event.getChannel())));
            }
            return eventHandler.handleEvent(event);
        } else {
            // action/options request
            SlackRequest request = new SlackRequest(content);
            String userId = getAuthUser(headers);
            // TODO: ability to map request.getUser() to corresponding MDW user
            String callbackId = request.getCallbackId();
            if (callbackId != null) {
                int underscore = callbackId.lastIndexOf('_');
                if (underscore > 0) {
                    String handlerType = callbackId.substring(0, underscore);
                    String id = callbackId.substring(callbackId.lastIndexOf('/') + 1);
                    ActionHandler actionHandler = getActionHandler(handlerType, userId, id,
                            request);
                    if (actionHandler == null)
                        throw new ServiceException("Unsupported handler type: " + handlerType);

                    return actionHandler.handleRequest(userId, id, request);
                }
            }
            throw new ServiceException(ServiceException.BAD_REQUEST, "Bad or missing callback_id");
        }
    }
440675
def post(self, url, post_params=None):
        
        post_params['token'] = self.token
        params = urlencode(post_params)
        logger.debug('Making POST request to %s with body %s', url, params)
        return requests.post(url, data=params)
37812
def do_POST(self):
        
        # Doesn't do anything with posted data
        # print "uri: ", self.client_address, self.path
        self.do_initial_operations()
        payload = self.coap_uri.get_payload()
        if payload is None:
            logger.error("BAD POST REQUEST")
            self.send_error(BAD_REQUEST)
            return
        coap_response = self.client.post(self.coap_uri.path, payload)
        self.client.stop()
        logger.info("Server response: %s", coap_response.pretty_print())
        self.set_http_response(coap_response)
853020
def make_request(self, path, params=None, data=None, method=None):
        '''
        
        '''
        # Setup values
        url = self.build_url(path, params)
        client_log.debug('Requesting:  %s' % url)
        method = method or 'GET'
        body = None
        headers = {}

        if data:
            method = 'POST'
            body = urlencode(data)
            headers = {
                'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
            }

        client_log.debug('Request Method:  %s' % method)
        client_log.debug('Request Body(Data):  %s' % data)
        client_log.debug('Request Body(Raw):  %s' % body)

        # Setup http client
        h = httplib2.Http(cache=self.cache, timeout=self.timeout)
        #h.add_credentials(self.username, self.password)
        # Skip the normal http client behavior and send auth headers immediately
        # to save an http request.
        headers['Authorization'] = "Basic %s" % base64.standard_b64encode(self.username + ':' + self.password).strip()

        # Make request
        response, content = h.request(url, method, body=body, headers=headers)
        status = response.status
        client_log.debug('Response Status:  %d' % status)
        client_log.debug('Response Content:  %s' % content)
        if status != 200 and status != 302:
            exception_class = CheddarError
            if status == 401:
                exception_class = AccessDenied
            elif status == 400:
                exception_class = BadRequest
            elif status == 404:
                exception_class = NotFound
            elif status == 412:
                exception_class = PreconditionFailed
            elif status == 500:
                exception_class = CheddarFailure
            elif status == 502:
                exception_class = NaughtyGateway
            elif status == 422:
                exception_class = UnprocessableEntity

            raise exception_class(response, content)

        response.content = content
        return response
180845
def post(self, path, params='', data=None):
        
        self.result = None
        data = data or {}
        headers = {'Content-Type': 'application/json',
                   'x-qx-client-application': self.client_application}
        url = str(self.credential.config['url'] + path + '?access_token=' +
                  self.credential.get_token() + params)
        retries = self.retries
        while retries > 0:
            respond = requests.post(url, data=data, headers=headers,
                                    verify=self.verify, **self.extra_args)
            if not self.check_token(respond):
                respond = requests.post(url, data=data, headers=headers,
                                        verify=self.verify,
                                        **self.extra_args)

            if self._response_good(respond):
                if self.result:
                    return self.result
                elif retries < 2:
                    return respond.json()
                else:
                    retries -= 1
            else:
                retries -= 1
                time.sleep(self.timeout_interval)

        # timed out
        raise ApiError(usr_msg='Failed to get proper ' +
                       'response from backend.')
1226429
def _post_json(path, object_to_post)
      resp = @rawclient.post(url(path), JSON.dump(object_to_post), {'Content-type' => 'application/json'})
      JSON.parse(resp.content)
    end
955698
def post(self, path, data=None):
        """"""
        data = data or {}
        response = requests.post(self.url(path), data=to_json(data), headers=self.request_header())
        return self.parse_response(response)
680868
def handleHttpPost(request, endpoint):
    
    if request.mimetype and request.mimetype != MIMETYPE:
        raise exceptions.UnsupportedMediaTypeException()
    request = request.get_data()
    if request == '' or request is None:
        request = '{}'
    responseStr = endpoint(request)
    return getFlaskResponse(responseStr)
584364
def request(method, path, options, raw=false, unformatted=true)
      response = connection(raw).send(method) do |request|
        path = formatted_path(path) unless unformatted
        case method
        when :get, :delete
          request.url(path, options)
        when :post, :put
          request.path = path
          request.body = options unless options.empty?
        end
      end
      raw ? response : response.body
    end
81864
def post(self, path, data, is_json=True):
        ''''''
        post_data = {
            'client_id': self.client_id,
            'secret': self.secret,
        }
        post_data.update(data)
        return self._post(path, post_data, is_json)
835181
def _post(self, uri, data, headers=None):
        
        if not headers:
            headers = self._get_headers()

        logging.debug("URI=" + str(uri))
        logging.debug("HEADERS=" + str(headers))
        logging.debug("BODY=" + str(data))

        response = self.session.post(uri, headers=headers,
                data=json.dumps(data))

        logging.debug("STATUS=" + str(response.status_code))
        if response.status_code in [200, 201]:
            return response.json()
        else:
            logging.error(b"ERROR=" + response.content)
            response.raise_for_status()
357515
def post(path, options={})
      response = request(:post, path, options)

      response.delete(:status) if response.respond_to?(:status)

      response
    end
816519
def post(self, url: str, data: str, expected_status_code=201):
        
        r = requests.post(self._format_url(url), json=data, headers=self.headers, timeout=TIMEOUT)
        self._check_response(r, expected_status_code)

        return r.json()