Skip to content

Instantly share code, notes, and snippets.

@dinhhuydh
Created June 17, 2019 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinhhuydh/e7bc42768120f714c2274277591b1500 to your computer and use it in GitHub Desktop.
Save dinhhuydh/e7bc42768120f714c2274277591b1500 to your computer and use it in GitHub Desktop.
Create product on Bitrix24 with inbound webhook API
# Resolve errors: Name is not specified
connection = Faraday.new(url: @@base_url)
connection.post do |req|
req.url 'crm.product.add'
req.headers['Content-Type'] = 'application/json'
req.body = { fields: { NAME: product_name, PRICE: estate.gia_khoi_diem, DESCRIPTION: product_description } }.to_json
end
@Jaimayal
Copy link

If anyone's reading this gist while trying to build anything around a Bitrix24 Inbound Webhook and facing the "Name is not specified" error, please consider that the data MUST travel via query parameters and not the request body.

For example, if i want to add a product with the req.body that is showcased on this gist the request URL should look like:
https://<WEBHOOK_URL>/crm.product.add.json?fields[NAME]=product_name&fields[PRICE]=estate.gia_khoi_Diem&fields[DESCRIPTION]=product_description

Found out about this by analyzing the code of the official JavaScript library. More specifically the function named "prepareData" on the custom "ajax" object seen on line 1139.

Hope this helps somebody someday!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment